-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* support string data * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * raise an error to avoid silence string truncation * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * poetry and version update * fix #125 * additional testing for wrong input types. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
1ad615e
commit 51b9b60
Showing
8 changed files
with
135 additions
and
41 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "znh5md" | ||
version = "0.3.4" | ||
version = "0.3.5" | ||
description = "ASE Interface for the H5MD format." | ||
authors = ["zincwarecode <[email protected]>"] | ||
license = "Apache-2.0" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import ase.build | ||
import pytest | ||
|
||
import znh5md | ||
|
||
|
||
def test_smiles(tmp_path): | ||
io = znh5md.IO(tmp_path / "test.h5") | ||
molecule = ase.build.molecule("H2O") | ||
molecule.info["smiles"] = "O" | ||
|
||
io.append(molecule) | ||
assert io[0].info["smiles"] == "O" | ||
|
||
molecule = ase.build.molecule("H2O2") | ||
molecule.info["smiles"] = "OO" | ||
|
||
io.append(molecule) | ||
assert io[0].info["smiles"] == "O" | ||
assert io[1].info["smiles"] == "OO" | ||
|
||
|
||
def test_very_long_text_data(tmp_path): | ||
io = znh5md.IO(tmp_path / "test.h5") | ||
molecule = ase.build.molecule("H2O") | ||
|
||
molecule.info["test"] = f"{list(range(1_000))}" | ||
with pytest.raises(ValueError, match="String test is too long to be stored."): | ||
io.append(molecule) | ||
|
||
|
||
def test_int_info_data(tmp_path): | ||
io = znh5md.IO(tmp_path / "test.h5") | ||
molecule = ase.build.molecule("H2O") | ||
molecule.info["test"] = 123 | ||
|
||
io.append(molecule) | ||
assert io[0].info["test"] == 123 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import ase.build | ||
import pytest | ||
|
||
import znh5md | ||
|
||
|
||
def test_extend_wrong_error(tmp_path): | ||
io = znh5md.IO(tmp_path / "test.h5") | ||
molecule = ase.build.molecule("H2O") | ||
|
||
with pytest.raises(ValueError, match="images must be a list of ASE Atoms objects"): | ||
io.extend(molecule) | ||
|
||
|
||
def test_append_wrong_error(tmp_path): | ||
io = znh5md.IO(tmp_path / "test.h5") | ||
molecule = ase.build.molecule("H2O") | ||
|
||
with pytest.raises(ValueError, match="atoms must be an ASE Atoms object"): | ||
io.append([molecule]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
|
||
|
||
def test_version(): | ||
assert znh5md.__version__ == "0.3.4" | ||
assert znh5md.__version__ == "0.3.5" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters