From 7c0e7d6bd20253e83feecb5ee75ea216b0d12991 Mon Sep 17 00:00:00 2001 From: Bas van Beek Date: Thu, 2 Dec 2021 17:19:34 +0100 Subject: [PATCH 1/4] TST: Adapt to the `Molecule.get_formula` changes made in PLAMS >1.5.1 xref nlesc-nano/CAT#212 --- setup.py | 7 ++++++- tests/test_bulk.py | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 8cc66d4..cd51aa7 100644 --- a/setup.py +++ b/setup.py @@ -79,6 +79,11 @@ 'flake8', ], extras_require={ - 'test': ['pytest', 'pytest-cov', 'pytest-mock'], + 'test': [ + 'pytest', + 'pytest-cov', + 'pytest-mock', + 'nlesc-CAT>=0.10.1', + ], } ) diff --git a/tests/test_bulk.py b/tests/test_bulk.py index a72d2db..37bfe51 100644 --- a/tests/test_bulk.py +++ b/tests/test_bulk.py @@ -14,6 +14,7 @@ from scm.plams import Molecule from scipy.spatial.distance import cdist from nanoCAT.recipes import bulk_workflow, fast_bulk_workflow +from CAT.utils import get_formula if TYPE_CHECKING: import _pytest @@ -45,7 +46,7 @@ def test_bulk_workflow() -> None: iterator = enumerate(zip(mol_list, formula_list), start=2) for i, (mol, formula) in iterator: assertion.eq(mol[i].coords, (0.0, 0.0, 0.0)) - assertion.eq(mol.get_formula(), formula) + assertion.eq(get_formula(mol), formula) ref = [17.07131616, 64.15117841, 74.79488029] np.testing.assert_allclose(bulk_ar, ref) From 64cea23bbeeda226089cc210a7ef1974f379bf06 Mon Sep 17 00:00:00 2001 From: Bas van Beek Date: Thu, 2 Dec 2021 17:20:10 +0100 Subject: [PATCH 2/4] MAINT,DOC: Fix a failure in the documentation generation --- nanoCAT/recipes/__init__.py | 7 ++++--- nanoCAT/recipes/coordination_number.py | 15 ++++++++++----- tests/test_coordination_number.py | 13 +++++++------ 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/nanoCAT/recipes/__init__.py b/nanoCAT/recipes/__init__.py index 21f11ec..9660daa 100644 --- a/nanoCAT/recipes/__init__.py +++ b/nanoCAT/recipes/__init__.py @@ -11,7 +11,7 @@ >>> from nanoCAT.recipes import bulk_workflow >>> from nanoCAT.recipes import get_lig_charge >>> from nanoCAT.recipes import replace_surface - >>> from nanoCAT.recipes import coordination_number + >>> from nanoCAT.recipes import get_coordination_number, coordination_outer >>> from nanoCAT.recipes import dissociate_surface, row_accumulator, dissociate_bulk >>> from nanoCAT.recipes import get_mol_length, filter_mol, filter_data >>> from nanoCAT.recipes import run_jobs, get_global_descriptors, cdft @@ -25,7 +25,7 @@ from .charges import get_lig_charge from .mark_surface import replace_surface from .dissociation import dissociate_surface, row_accumulator, dissociate_bulk -from .coordination_number import coordination_number +from .coordination_number import get_coordination_number, coordination_outer from .multi_lig_job import multi_ligand_job from .mol_filter import get_mol_length, filter_mol, filter_data from .cdft_utils import run_jobs, get_global_descriptors, cdft @@ -35,7 +35,8 @@ __all__ = [ 'bulk_workflow', 'fast_bulk_workflow', 'replace_surface', 'dissociate_surface', 'dissociate_bulk', - 'row_accumulator', 'get_lig_charge', 'coordination_number', + 'row_accumulator', 'get_lig_charge', + 'get_coordination_number', 'coordination_outer', 'multi_ligand_job', 'get_mol_length', 'filter_mol', 'filter_data', 'run_jobs', 'get_global_descriptors', 'cdft', diff --git a/nanoCAT/recipes/coordination_number.py b/nanoCAT/recipes/coordination_number.py index 53b4532..bc66508 100644 --- a/nanoCAT/recipes/coordination_number.py +++ b/nanoCAT/recipes/coordination_number.py @@ -8,11 +8,13 @@ ----- .. currentmodule:: nanoCAT.recipes .. autosummary:: - coordination_number + get_coordination_number + coordination_outer API --- -.. autofunction:: coordination_number +.. autofunction:: get_coordination_number +.. autofunction:: coordination_outer """ @@ -26,7 +28,7 @@ from nanoutils import group_by_values from nanoCAT.bde.guess_core_dist import guess_core_core_dist -__all__: List[str] = ['coordination_number', 'coordination_outer'] +__all__ = ['get_coordination_number', 'coordination_outer'] #: A nested dictonary NestedDict = Dict[str, Dict[int, List[int]]] @@ -116,8 +118,8 @@ def map_coordination(coord: np.ndarray, idx_dict: Dict[str, np.ndarray]) -> Nest return cn_dict -def coordination_number(mol: Molecule, shell: str = 'inner', - d_outer: Optional[float] = None) -> NestedDict: +def get_coordination_number(mol: Molecule, shell: str = 'inner', + d_outer: Optional[float] = None) -> NestedDict: """Take a molecule and identify the coordination number of each atom. The function first compute the pair distance between all reference atoms in **mol**. @@ -192,3 +194,6 @@ def coordination_number(mol: Molecule, shell: str = 'inner', # Return the final dictionary return map_coordination(coord, idx_dict) + + +coordination_number = get_coordination_number diff --git a/tests/test_coordination_number.py b/tests/test_coordination_number.py index a0f143e..0935c51 100644 --- a/tests/test_coordination_number.py +++ b/tests/test_coordination_number.py @@ -7,18 +7,18 @@ from scm.plams import Molecule from assertionlib import assertion -from nanoCAT.recipes import coordination_number +from nanoCAT.recipes import get_coordination_number PATH = Path('tests') / 'test_files' MOL = Molecule(PATH / 'Cd68Se55.xyz') def test_coordination_number() -> None: - """Tests for :func:`nanoCAT.recipes.coordination_number`.""" + """Tests for :func:`nanoCAT.recipes.get_coordination_number`.""" - out_inner = coordination_number(MOL, shell='inner') + out_inner = get_coordination_number(MOL, shell='inner') - out_outer = coordination_number(MOL, shell='outer', d_outer=5.2) + out_outer = get_coordination_number(MOL, shell='outer', d_outer=5.2) ref_inner = {'Cd': {3: [30, 31, 34, 35, 36, 46, 47, 52, 53, 54, 57, 58, 59, 60, 63, 64, 65, 67, 69, 70, 71, 75, 78, 79], @@ -50,5 +50,6 @@ def test_coordination_number() -> None: np.testing.assert_equal(out_inner, ref_inner) np.testing.assert_equal(out_outer, ref_outer) - assertion.assert_(coordination_number, MOL, shell='bob', exception=ValueError) - assertion.assert_(coordination_number, MOL, shell='outer', d_outer=None, exception=TypeError) + assertion.assert_(get_coordination_number, MOL, shell='bob', exception=ValueError) + assertion.assert_(get_coordination_number, MOL, shell='outer', d_outer=None, + exception=TypeError) From 2d1b7ff78aa174d9a45afb04e7687a8426dde551 Mon Sep 17 00:00:00 2001 From: Bas van Beek Date: Thu, 2 Dec 2021 17:21:12 +0100 Subject: [PATCH 3/4] DOC: Add a pypi badge --- README.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.rst b/README.rst index 2fb0bdb..bae64d0 100644 --- a/README.rst +++ b/README.rst @@ -2,6 +2,8 @@ :target: https://github.com/nlesc-nano/nano-CAT/actions?query=workflow%3A%22Build+with+Conda%22 .. image:: https://readthedocs.org/projects/cat/badge/?version=latest :target: https://cat.readthedocs.io/en/latest/ +.. image:: https://badge.fury.io/py/nano-CAT.svg + :target: https://badge.fury.io/py/nano-CAT | From cfb0b1f9d896404278ad29a76566d4765a909aef Mon Sep 17 00:00:00 2001 From: Bas van Beek Date: Thu, 2 Dec 2021 17:22:51 +0100 Subject: [PATCH 4/4] REL: Nano-CAT version bump: 0.7.0 -> 0.7.1 --- CHANGELOG.rst | 7 +++++++ README.rst | 2 +- nanoCAT/__version__.py | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 534d8aa..8f343cf 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,13 @@ Change Log All notable changes to this project will be documented in this file. This project adheres to `Semantic Versioning `_. + +0.7.1 +***** +* Deprecate usage of ``Molecule.get_formula`` in favor of a PLAMS <=1.5.1-based backport. +* Fix a failure in the documentation generation + + 0.7.0 ***** * Added a new fast-bulkiness workflow. diff --git a/README.rst b/README.rst index bae64d0..5b84c42 100644 --- a/README.rst +++ b/README.rst @@ -16,7 +16,7 @@ ############## -Nano-CAT 0.7.0 +Nano-CAT 0.7.1 ############## **Nano-CAT** is a collection of tools for the analysis of nanocrystals, diff --git a/nanoCAT/__version__.py b/nanoCAT/__version__.py index a71c5c7..f0788a8 100644 --- a/nanoCAT/__version__.py +++ b/nanoCAT/__version__.py @@ -1 +1 @@ -__version__ = '0.7.0' +__version__ = '0.7.1'