From 96f4a919fab0f595de84338a00928693165e2a9e Mon Sep 17 00:00:00 2001 From: "Jose M. Pizarro" <112697669+JosePizarro3@users.noreply.github.com> Date: Wed, 18 Sep 2024 08:58:09 +0200 Subject: [PATCH 1/3] Added check_simulation_cell in utils (#117) * Added equal cell tolerance * Defining logic in __eq__ methods of Cell and AtomicCell * Moved testing to test_model_system Added __ne__ method * Add todo * Fix == testing failing * Added __ne__ testing --- .../schema_packages/__init__.py | 10 +- .../schema_packages/model_system.py | 57 +++++++ .../schema_packages/utils/utils.py | 7 + tests/test_model_system.py | 154 ++++++++++++++++++ tests/test_utils.py | 17 +- 5 files changed, 238 insertions(+), 7 deletions(-) diff --git a/src/nomad_simulations/schema_packages/__init__.py b/src/nomad_simulations/schema_packages/__init__.py index 183fab03..d7b6e939 100644 --- a/src/nomad_simulations/schema_packages/__init__.py +++ b/src/nomad_simulations/schema_packages/__init__.py @@ -23,11 +23,11 @@ class NOMADSimulationsEntryPoint(SchemaPackageEntryPoint): dos_energy_tolerance: float = Field( 8.01088e-21, - description='Tolerance of the DOS energies in Joules to match the reference of energies in the DOS normalize function.', + description='Tolerance (in joules) of the DOS energies to match the reference of energies in the DOS normalize function.', ) dos_intensities_threshold: float = Field( 1e-8, - description='Threshold value at which the DOS intensities are considered non-zero.', + description='Threshold value (in joules^-1) at which the DOS intensities are considered non-zero.', ) occupation_tolerance: float = Field( 1e-3, @@ -35,7 +35,7 @@ class NOMADSimulationsEntryPoint(SchemaPackageEntryPoint): ) fermi_surface_tolerance: float = Field( 1e-8, - description='Tolerance for energies to be close to the Fermi level and hence define the Fermi surface of a material.', + description='Tolerance (in joules) for energies to be close to the Fermi level and hence define the Fermi surface of a material.', ) symmetry_tolerance: float = Field( 0.1, description='Tolerance for the symmetry analyzer used from MatID.' @@ -48,6 +48,10 @@ class NOMADSimulationsEntryPoint(SchemaPackageEntryPoint): 64, description='Limite of the number of atoms in the unit cell to be treated for the system type classification from MatID to work. This is done to avoid overhead of the package.', ) + equal_cell_positions_tolerance: float = Field( + 1e-12, + description='Tolerance (in meters) for the cell positions to be considered equal.', + ) def load(self): from nomad_simulations.schema_packages.general import m_package diff --git a/src/nomad_simulations/schema_packages/model_system.py b/src/nomad_simulations/schema_packages/model_system.py index 01ebb30e..e6276a3f 100644 --- a/src/nomad_simulations/schema_packages/model_system.py +++ b/src/nomad_simulations/schema_packages/model_system.py @@ -296,6 +296,40 @@ class Cell(GeometricSpace): """, ) + def _check_positions(self, positions_1, positions_2) -> list: + # Check that all the `positions`` of `cell_1` match with the ones in `cell_2` + check_positions = [] + for i1, pos1 in enumerate(positions_1): + for i2, pos2 in enumerate(positions_2): + if np.allclose( + pos1, pos2, atol=configuration.equal_cell_positions_tolerance + ): + check_positions.append([i1, i2]) + break + return check_positions + + def __eq__(self, other) -> bool: + # TODO implement checks on `lattice_vectors` and other quantities to ensure the equality of primitive cells + if not isinstance(other, Cell): + return False + + # If the `positions` are empty, return False + if self.positions is None or other.positions is None: + return False + + # The `positions` should have the same length (same number of positions) + if len(self.positions) != len(other.positions): + return False + n_positions = len(self.positions) + + check_positions = self._check_positions(self.positions, other.positions) + if len(check_positions) != n_positions: + return False + return True + + def __ne__(self, other) -> bool: + return not self.__eq__(other) + def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None: super().normalize(archive, logger) @@ -339,6 +373,29 @@ def __init__(self, m_def: 'Section' = None, m_context: 'Context' = None, **kwarg # Set the name of the section self.name = self.m_def.name + def __eq__(self, other) -> bool: + if not isinstance(other, AtomicCell): + return False + + # Compare positions using the parent sections's `__eq__` method + if not super().__eq__(other): + return False + + # Check that the `chemical_symbol` of the atoms in `cell_1` match with the ones in `cell_2` + check_positions = self._check_positions(self.positions, other.positions) + try: + for atom in check_positions: + element_1 = self.atoms_state[atom[0]].chemical_symbol + element_2 = other.atoms_state[atom[1]].chemical_symbol + if element_1 != element_2: + return False + except Exception: + return False + return True + + def __ne__(self, other) -> bool: + return not self.__eq__(other) + def to_ase_atoms(self, logger: 'BoundLogger') -> Optional[ase.Atoms]: """ Generates an ASE Atoms object with the most basic information from the parsed `AtomicCell` diff --git a/src/nomad_simulations/schema_packages/utils/utils.py b/src/nomad_simulations/schema_packages/utils/utils.py index ac5ee561..e925b53b 100644 --- a/src/nomad_simulations/schema_packages/utils/utils.py +++ b/src/nomad_simulations/schema_packages/utils/utils.py @@ -21,6 +21,7 @@ from typing import TYPE_CHECKING import numpy as np +from nomad.config import config if TYPE_CHECKING: from typing import Optional @@ -28,6 +29,12 @@ from nomad.datamodel.data import ArchiveSection from structlog.stdlib import BoundLogger + from nomad_simulations.schema_packages.model_system import Cell + +configuration = config.get_plugin_entry_point( + 'nomad_simulations.schema_packages:nomad_simulations_plugin' +) + def get_sibling_section( section: 'ArchiveSection', diff --git a/tests/test_model_system.py b/tests/test_model_system.py index 6ead47e8..e189ace8 100644 --- a/tests/test_model_system.py +++ b/tests/test_model_system.py @@ -22,7 +22,10 @@ import pytest from nomad.datamodel import EntryArchive +from nomad_simulations.schema_packages.atoms_state import AtomsState from nomad_simulations.schema_packages.model_system import ( + AtomicCell, + Cell, ChemicalFormula, ModelSystem, Symmetry, @@ -32,11 +35,162 @@ from .conftest import generate_atomic_cell +class TestCell: + """ + Test the `Cell` section defined in model_system.py + """ + + @pytest.mark.parametrize( + 'cell_1, cell_2, result', + [ + (Cell(), None, False), # one cell is None + (Cell(), Cell(), False), # both cells are empty + ( + Cell(positions=[[1, 0, 0]]), + Cell(), + False, + ), # one cell has positions, the other is empty + ( + Cell(positions=[[1, 0, 0], [0, 1, 0]]), + Cell(positions=[[1, 0, 0]]), + False, + ), # length mismatch + ( + Cell(positions=[[1, 0, 0], [0, 1, 0]]), + Cell(positions=[[1, 0, 0], [0, -1, 0]]), + False, + ), # different positions + ( + Cell(positions=[[1, 0, 0], [0, 1, 0], [0, 0, 1]]), + Cell(positions=[[1, 0, 0], [0, 1, 0], [0, 0, 1]]), + True, + ), # same ordered positions + ( + Cell(positions=[[1, 0, 0], [0, 1, 0], [0, 0, 1]]), + Cell(positions=[[1, 0, 0], [0, 0, 1], [0, 1, 0]]), + True, + ), # different ordered positions but same cell + ], + ) + def test_eq_ne(self, cell_1: Cell, cell_2: Cell, result: bool): + """ + Test the `__eq__` and `__ne__` operator functions of `Cell`. + """ + assert (cell_1 == cell_2) == result + assert (cell_1 != cell_2) != result + + class TestAtomicCell: """ Test the `AtomicCell`, `Cell` and `GeometricSpace` classes defined in model_system.py """ + @pytest.mark.parametrize( + 'cell_1, cell_2, result', + [ + (Cell(), None, False), # one cell is None + (Cell(), Cell(), False), # both cells are empty + ( + Cell(positions=[[1, 0, 0]]), + Cell(), + False, + ), # one cell has positions, the other is empty + ( + Cell(positions=[[1, 0, 0], [0, 1, 0]]), + Cell(positions=[[1, 0, 0]]), + False, + ), # length mismatch + ( + Cell(positions=[[1, 0, 0], [0, 1, 0]]), + Cell(positions=[[1, 0, 0], [0, -1, 0]]), + False, + ), # different positions + ( + Cell(positions=[[1, 0, 0], [0, 1, 0], [0, 0, 1]]), + Cell(positions=[[1, 0, 0], [0, 1, 0], [0, 0, 1]]), + True, + ), # same ordered positions + ( + Cell(positions=[[1, 0, 0], [0, 1, 0], [0, 0, 1]]), + Cell(positions=[[1, 0, 0], [0, 0, 1], [0, 1, 0]]), + True, + ), # different ordered positions but same cell + ( + AtomicCell(positions=[[1, 0, 0], [0, 1, 0], [0, 0, 1]]), + Cell(positions=[[1, 0, 0], [0, 1, 0], [0, 0, 1]]), + False, + ), # one atomic cell and another cell (missing chemical symbols) + ( + AtomicCell(positions=[[1, 0, 0], [0, 1, 0], [0, 0, 1]]), + AtomicCell(positions=[[1, 0, 0], [0, 1, 0], [0, 0, 1]]), + False, + ), # missing chemical symbols + ( + AtomicCell( + positions=[[1, 0, 0], [0, 1, 0], [0, 0, 1]], + atoms_state=[ + AtomsState(chemical_symbol='H'), + AtomsState(chemical_symbol='H'), + AtomsState(chemical_symbol='O'), + ], + ), + AtomicCell( + positions=[[1, 0, 0], [0, 1, 0], [0, 0, 1]], + atoms_state=[ + AtomsState(chemical_symbol='H'), + AtomsState(chemical_symbol='H'), + AtomsState(chemical_symbol='O'), + ], + ), + True, + ), # same ordered positions and chemical symbols + ( + AtomicCell( + positions=[[1, 0, 0], [0, 1, 0], [0, 0, 1]], + atoms_state=[ + AtomsState(chemical_symbol='H'), + AtomsState(chemical_symbol='H'), + AtomsState(chemical_symbol='O'), + ], + ), + AtomicCell( + positions=[[1, 0, 0], [0, 1, 0], [0, 0, 1]], + atoms_state=[ + AtomsState(chemical_symbol='H'), + AtomsState(chemical_symbol='Cu'), + AtomsState(chemical_symbol='O'), + ], + ), + False, + ), # same ordered positions but different chemical symbols + ( + AtomicCell( + positions=[[1, 0, 0], [0, 1, 0], [0, 0, 1]], + atoms_state=[ + AtomsState(chemical_symbol='H'), + AtomsState(chemical_symbol='H'), + AtomsState(chemical_symbol='O'), + ], + ), + AtomicCell( + positions=[[1, 0, 0], [0, 0, 1], [0, 1, 0]], + atoms_state=[ + AtomsState(chemical_symbol='H'), + AtomsState(chemical_symbol='O'), + AtomsState(chemical_symbol='H'), + ], + ), + True, + ), # different ordered positions but same chemical symbols + ], + ) + def test_eq_ne(self, cell_1: Cell, cell_2: Cell, result: bool): + """ + Test the `__eq__` and `__ne__` operator functions of `AtomicCell`. + """ + assert (cell_1 == cell_2) == result + assert (cell_1 != cell_2) != result + @pytest.mark.parametrize( 'chemical_symbols, atomic_numbers, formula, lattice_vectors, positions, periodic_boundary_conditions', [ diff --git a/tests/test_utils.py b/tests/test_utils.py index 3d3e69cf..26f8a5d4 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -45,16 +45,25 @@ def test_get_sibling_section(): parent_section.symmetry.append(sibling_section) assert get_sibling_section(section, '', logger) is None assert get_sibling_section(section, 'symmetry', logger) == sibling_section - assert get_sibling_section(sibling_section, 'cell', logger) == section + assert get_sibling_section(sibling_section, 'cell', logger).type == section.type assert get_sibling_section(section, 'symmetry', logger, index_sibling=2) is None section2 = AtomicCell(type='primitive') parent_section.cell.append(section2) assert ( - get_sibling_section(sibling_section, 'cell', logger, index_sibling=0) == section + get_sibling_section(sibling_section, 'cell', logger, index_sibling=0).type + == 'original' ) assert ( - get_sibling_section(sibling_section, 'cell', logger, index_sibling=1) - == section2 + get_sibling_section(sibling_section, 'cell', logger, index_sibling=0).type + == section.type + ) + assert ( + get_sibling_section(sibling_section, 'cell', logger, index_sibling=1).type + == section2.type + ) + assert ( + get_sibling_section(sibling_section, 'cell', logger, index_sibling=1).type + == 'primitive' ) From 349d80f33d5eddd38f8fbac39c1edd9648db40e5 Mon Sep 17 00:00:00 2001 From: Joseph Rudzinski Date: Tue, 24 Sep 2024 15:18:40 +0200 Subject: [PATCH 2/3] added cff file for Zenodo publishing (#128) * added cff file for Zenodo publishing * added Esmas orcid * description and author order * title * Zenodo badge setup * added Alvin * citation in Readme * updated citation --------- Co-authored-by: jrudz --- CITATION.cff | 36 ++++++++++++++++++++++++++++++++++++ README.md | 3 +++ 2 files changed, 39 insertions(+) create mode 100644 CITATION.cff diff --git a/CITATION.cff b/CITATION.cff new file mode 100644 index 00000000..c3ed0fb7 --- /dev/null +++ b/CITATION.cff @@ -0,0 +1,36 @@ +cff-version: 1.2.0 +title: NOMAD Simulations +message: >- + If you use this software, please cite it using the + metadata from this file. +type: software +authors: + - given-names: José M. + family-names: Pizarro + orcid: 'https://orcid.org/0000-0002-6751-8192' + - given-names: Esma B. + family-names: Boydas + orcid: 'https://orcid.org/0009-0005-6729-4706' + - given-names: Nathan + family-names: Daelman + orcid: 'https://orcid.org/0000-0002-7647-1816' + - given-names: Alvin Noe + family-names: Ladines + orcid: 'https://orcid.org/0000-0003-0077-2097' + - given-names: Bernadette + family-names: Mohr + orcid: 'https://orcid.org/0000-0003-0903-0073' + - given-names: Joseph F. + family-names: Rudzinski + orcid: 'https://orcid.org/0000-0003-3403-640X' +doi: +repository-code: 'https://github.com/nomad-coe/nomad-simulations' +url: 'https://nomad-coe.github.io/nomad-simulations/' +abstract: >- + `nomad-simulations` is a plugin for the NOMAD software (https://zenodo.org/doi/10.5281/zenodo.8366162) + providing a common data standard and analysis tools for parsed Materials Science and Quantum Chemistry + simulations. This standard is used as a template and is populated by the many available NOMAD parsers to transform their + inputs / outputs into a structured data format. This plugin is community-driven, and users are encourage to + contribute towards providing Findable, Accessible, Interoperable, and Reusable (FAIR) data. + +license: Apache-2.0 \ No newline at end of file diff --git a/README.md b/README.md index fdceed16..8bf9ba1d 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ ![](https://coveralls.io/repos/github/nomad-coe/nomad-simulations/badge.svg?branch=develop) ![](https://img.shields.io/pypi/v/nomad-simulations) ![](https://img.shields.io/pypi/pyversions/nomad-simulations) +[![DOI](https://zenodo.org/badge/744481756.svg)](https://zenodo.org/badge/latestdoi/744481756) @@ -160,6 +161,8 @@ plugins: **Note!** Once you modify your `nomad.yaml` file adding `include`, all the default plugins will be disconnected, so you will need to include them as well. +## How to cite this work +Pizarro, J.M., Boydas, E.B., Daelman, N., Ladines, A.N., Mohr, B. & Rudzinski, J.F., NOMAD Simulations [Computer software]. https://doi.org/xxxxx ## Main contributors | Name | E-mail | Topics | Github profiles | From 5d162aa49b99d881ad69c71a56b26519ab9358fe Mon Sep 17 00:00:00 2001 From: "Jose M. Pizarro" <112697669+JosePizarro3@users.noreply.github.com> Date: Wed, 25 Sep 2024 08:38:02 +0200 Subject: [PATCH 3/3] 126 minor fixes (#127) * Fix warning spectral_profile Fix README Move testing files to subfolders to mimic src structure * Deleted copyright notice at the beginning of each file * Changed __eq__ (and __ne__) for function is_equal_cell * Fix conftest imports --- README.md | 17 ++++-- .../schema_packages/__init__.py | 18 ------- .../schema_packages/atoms_state.py | 18 ------- .../schema_packages/general.py | 18 ------- .../schema_packages/model_method.py | 18 ------- .../schema_packages/model_system.py | 53 +++++++++---------- .../schema_packages/numerical_settings.py | 18 ------- .../schema_packages/outputs.py | 18 ------- .../schema_packages/physical_property.py | 18 ------- .../schema_packages/properties/__init__.py | 18 ------- .../schema_packages/properties/band_gap.py | 18 ------- .../properties/band_structure.py | 18 ------- .../schema_packages/properties/energies.py | 18 ------- .../properties/fermi_surface.py | 18 ------- .../schema_packages/properties/forces.py | 19 ------- .../properties/greens_function.py | 18 ------- .../properties/hopping_matrix.py | 18 ------- .../properties/permittivity.py | 18 ------- .../properties/spectral_profile.py | 20 +------ .../properties/thermodynamics.py | 18 ------- .../schema_packages/utils/__init__.py | 18 ------- .../schema_packages/utils/utils.py | 21 -------- .../schema_packages/variables.py | 18 ------- tests/__init__.py | 18 ------- tests/conftest.py | 18 ------- tests/properties/__init__.py | 3 ++ tests/{ => properties}/test_band_gap.py | 18 ------- tests/{ => properties}/test_band_structure.py | 20 +------ tests/{ => properties}/test_energies.py | 18 ------- tests/{ => properties}/test_fermi_surface.py | 18 ------- tests/properties/test_forces.py | 17 ++++++ .../{ => properties}/test_greens_function.py | 18 ------- tests/{ => properties}/test_hopping_matrix.py | 18 ------- tests/{ => properties}/test_permittivity.py | 20 +------ .../{ => properties}/test_spectral_profile.py | 18 ------- tests/test_atoms_state.py | 18 ------- tests/test_forces.py | 35 ------------ tests/test_general.py | 18 ------- tests/test_model_method.py | 18 ------- tests/test_model_system.py | 32 +++-------- tests/test_numerical_settings.py | 18 ------- tests/test_outputs.py | 18 ------- tests/test_physical_properties.py | 18 ------- tests/test_variables.py | 18 ------- tests/utils/__init__.py | 3 ++ tests/{ => utils}/test_utils.py | 18 ------- 46 files changed, 70 insertions(+), 802 deletions(-) create mode 100644 tests/properties/__init__.py rename tests/{ => properties}/test_band_gap.py (85%) rename tests/{ => properties}/test_band_structure.py (94%) rename tests/{ => properties}/test_energies.py (79%) rename tests/{ => properties}/test_fermi_surface.py (65%) create mode 100644 tests/properties/test_forces.py rename tests/{ => properties}/test_greens_function.py (89%) rename tests/{ => properties}/test_hopping_matrix.py (79%) rename tests/{ => properties}/test_permittivity.py (88%) rename tests/{ => properties}/test_spectral_profile.py (94%) delete mode 100644 tests/test_forces.py create mode 100644 tests/utils/__init__.py rename tests/{ => utils}/test_utils.py (81%) diff --git a/README.md b/README.md index 8bf9ba1d..a9314655 100644 --- a/README.md +++ b/README.md @@ -8,14 +8,20 @@ # `nomad-simulations` -This is a plugin for [NOMAD](https://nomad-lab.eu) which contains the base sections definitions for materials science simulations. This schema can be used at any prefered level by the user, it can be modified and extended, and we welcome external collaborators. +The `nomad-simulations` is an open-source Python package for managing Materials Science simulation data. It is following the plugin architechture of [NOMAD](https://nomad-lab.eu). This package contains a set of section definitions (Python classes) with quantities (attributes) and methods defined to automate data extraction from different simulation codes. These section definitions can be used at any prefered level by the user, they can be modified and extended, and we welcome external collaborators. + +Read more in the [official documentation](https://nomad-coe.github.io/nomad-simulations/) page. ## Getting started `nomad-simulations` can be installed as a PyPI package using `pip`: + +> [!WARNING] +> Unfortunately, the current plugin mechanism is not supported by the latest nomad-lab version on PyPI and therefore an index url pointing to the NOMAD Gitlab registry needs to be added. + ```sh -pip install nomad-simulations +pip install nomad-simulations --index-url https://gitlab.mpcdf.mpg.de/api/v4/projects/2187/packages/pypi/simple ``` @@ -49,6 +55,11 @@ The plugin is still under development. If you would like to contribute, install uv pip install -e '.[dev]' ``` +**Note:** If you do not use `uv`, you need to add the `--index-url` flag as in the PyPI command for installing the package: +```sh +pip install -e '.[dev]' --index-url https://gitlab.mpcdf.mpg.de/api/v4/projects/2187/packages/pypi/simple +``` + ### Run the tests @@ -139,7 +150,7 @@ Read the [NOMAD plugin documentation](https://nomad-lab.eu/prod/v1/staging/docs/ Modify the script under `/nomad/scripts/install_default_plugins.sh` and add the path to this repository pointing to the `@develop` branch: ```sh -pip install git+https://github.com/nomad-coe/nomad-simulations.git@develop +git+https://github.com/nomad-coe/nomad-simulations.git@develop ``` Then, go to your NOMAD folder, activate your NOMAD virtual environment and run: diff --git a/src/nomad_simulations/schema_packages/__init__.py b/src/nomad_simulations/schema_packages/__init__.py index d7b6e939..8b730793 100644 --- a/src/nomad_simulations/schema_packages/__init__.py +++ b/src/nomad_simulations/schema_packages/__init__.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from nomad.config.models.plugins import SchemaPackageEntryPoint from pydantic import Field diff --git a/src/nomad_simulations/schema_packages/atoms_state.py b/src/nomad_simulations/schema_packages/atoms_state.py index 72ddb2f3..32fbdd11 100644 --- a/src/nomad_simulations/schema_packages/atoms_state.py +++ b/src/nomad_simulations/schema_packages/atoms_state.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from typing import TYPE_CHECKING, Any, Optional, Union import ase diff --git a/src/nomad_simulations/schema_packages/general.py b/src/nomad_simulations/schema_packages/general.py index d38de349..9a2d48f0 100644 --- a/src/nomad_simulations/schema_packages/general.py +++ b/src/nomad_simulations/schema_packages/general.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from typing import TYPE_CHECKING if TYPE_CHECKING: diff --git a/src/nomad_simulations/schema_packages/model_method.py b/src/nomad_simulations/schema_packages/model_method.py index 2ef35b89..ac5daa82 100644 --- a/src/nomad_simulations/schema_packages/model_method.py +++ b/src/nomad_simulations/schema_packages/model_method.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - import re from typing import TYPE_CHECKING, Optional diff --git a/src/nomad_simulations/schema_packages/model_system.py b/src/nomad_simulations/schema_packages/model_system.py index e6276a3f..0a1897d1 100644 --- a/src/nomad_simulations/schema_packages/model_system.py +++ b/src/nomad_simulations/schema_packages/model_system.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - import re from typing import TYPE_CHECKING, Optional @@ -308,7 +290,14 @@ def _check_positions(self, positions_1, positions_2) -> list: break return check_positions - def __eq__(self, other) -> bool: + def is_equal_cell(self, other) -> bool: + """ + Check if the cell is equal to an`other` cell by comparing the `positions`. + Args: + other: The other cell to compare with. + Returns: + bool: True if the cells are equal, False otherwise. + """ # TODO implement checks on `lattice_vectors` and other quantities to ensure the equality of primitive cells if not isinstance(other, Cell): return False @@ -322,14 +311,13 @@ def __eq__(self, other) -> bool: return False n_positions = len(self.positions) - check_positions = self._check_positions(self.positions, other.positions) + check_positions = self._check_positions( + positions_1=self.positions, positions_2=other.positions + ) if len(check_positions) != n_positions: return False return True - def __ne__(self, other) -> bool: - return not self.__eq__(other) - def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None: super().normalize(archive, logger) @@ -373,16 +361,26 @@ def __init__(self, m_def: 'Section' = None, m_context: 'Context' = None, **kwarg # Set the name of the section self.name = self.m_def.name - def __eq__(self, other) -> bool: + def is_equal_cell(self, other) -> bool: + """ + Check if the atomic cell is equal to an`other` atomic cell by comparing the `positions` and + the `AtomsState[*].chemical_symbol`. + Args: + other: The other atomic cell to compare with. + Returns: + bool: True if the atomic cells are equal, False otherwise. + """ if not isinstance(other, AtomicCell): return False # Compare positions using the parent sections's `__eq__` method - if not super().__eq__(other): + if not super().is_equal_cell(other=other): return False # Check that the `chemical_symbol` of the atoms in `cell_1` match with the ones in `cell_2` - check_positions = self._check_positions(self.positions, other.positions) + check_positions = self._check_positions( + positions_1=self.positions, positions_2=other.positions + ) try: for atom in check_positions: element_1 = self.atoms_state[atom[0]].chemical_symbol @@ -393,9 +391,6 @@ def __eq__(self, other) -> bool: return False return True - def __ne__(self, other) -> bool: - return not self.__eq__(other) - def to_ase_atoms(self, logger: 'BoundLogger') -> Optional[ase.Atoms]: """ Generates an ASE Atoms object with the most basic information from the parsed `AtomicCell` diff --git a/src/nomad_simulations/schema_packages/numerical_settings.py b/src/nomad_simulations/schema_packages/numerical_settings.py index 4a36e8f1..515deea7 100644 --- a/src/nomad_simulations/schema_packages/numerical_settings.py +++ b/src/nomad_simulations/schema_packages/numerical_settings.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from itertools import accumulate, chain, tee from typing import TYPE_CHECKING, Optional, Union diff --git a/src/nomad_simulations/schema_packages/outputs.py b/src/nomad_simulations/schema_packages/outputs.py index 4b673ef9..1491fda3 100644 --- a/src/nomad_simulations/schema_packages/outputs.py +++ b/src/nomad_simulations/schema_packages/outputs.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from typing import TYPE_CHECKING, Optional import numpy as np diff --git a/src/nomad_simulations/schema_packages/physical_property.py b/src/nomad_simulations/schema_packages/physical_property.py index af478fc0..5bb728bc 100644 --- a/src/nomad_simulations/schema_packages/physical_property.py +++ b/src/nomad_simulations/schema_packages/physical_property.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from functools import wraps from typing import TYPE_CHECKING, Any, Optional diff --git a/src/nomad_simulations/schema_packages/properties/__init__.py b/src/nomad_simulations/schema_packages/properties/__init__.py index 435738cc..69470a4f 100644 --- a/src/nomad_simulations/schema_packages/properties/__init__.py +++ b/src/nomad_simulations/schema_packages/properties/__init__.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. -# See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - from .band_gap import ElectronicBandGap from .band_structure import ElectronicBandStructure, ElectronicEigenvalues, Occupancy from .energies import ( diff --git a/src/nomad_simulations/schema_packages/properties/band_gap.py b/src/nomad_simulations/schema_packages/properties/band_gap.py index ee7c12dd..05c1ba57 100644 --- a/src/nomad_simulations/schema_packages/properties/band_gap.py +++ b/src/nomad_simulations/schema_packages/properties/band_gap.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from typing import TYPE_CHECKING, Optional import numpy as np diff --git a/src/nomad_simulations/schema_packages/properties/band_structure.py b/src/nomad_simulations/schema_packages/properties/band_structure.py index f2c89b5f..c5e169b0 100644 --- a/src/nomad_simulations/schema_packages/properties/band_structure.py +++ b/src/nomad_simulations/schema_packages/properties/band_structure.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from typing import TYPE_CHECKING, Optional, Union import numpy as np diff --git a/src/nomad_simulations/schema_packages/properties/energies.py b/src/nomad_simulations/schema_packages/properties/energies.py index 7ab68fe7..c726c4da 100644 --- a/src/nomad_simulations/schema_packages/properties/energies.py +++ b/src/nomad_simulations/schema_packages/properties/energies.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from typing import TYPE_CHECKING import numpy as np diff --git a/src/nomad_simulations/schema_packages/properties/fermi_surface.py b/src/nomad_simulations/schema_packages/properties/fermi_surface.py index 9829bff0..231e15ed 100644 --- a/src/nomad_simulations/schema_packages/properties/fermi_surface.py +++ b/src/nomad_simulations/schema_packages/properties/fermi_surface.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from typing import TYPE_CHECKING import numpy as np diff --git a/src/nomad_simulations/schema_packages/properties/forces.py b/src/nomad_simulations/schema_packages/properties/forces.py index b47048f6..cedf72f1 100644 --- a/src/nomad_simulations/schema_packages/properties/forces.py +++ b/src/nomad_simulations/schema_packages/properties/forces.py @@ -1,22 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. -# See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from typing import TYPE_CHECKING import numpy as np diff --git a/src/nomad_simulations/schema_packages/properties/greens_function.py b/src/nomad_simulations/schema_packages/properties/greens_function.py index 51928a84..3da09e53 100644 --- a/src/nomad_simulations/schema_packages/properties/greens_function.py +++ b/src/nomad_simulations/schema_packages/properties/greens_function.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from typing import TYPE_CHECKING import numpy as np diff --git a/src/nomad_simulations/schema_packages/properties/hopping_matrix.py b/src/nomad_simulations/schema_packages/properties/hopping_matrix.py index 795ce5fb..094c901d 100644 --- a/src/nomad_simulations/schema_packages/properties/hopping_matrix.py +++ b/src/nomad_simulations/schema_packages/properties/hopping_matrix.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from typing import TYPE_CHECKING import numpy as np diff --git a/src/nomad_simulations/schema_packages/properties/permittivity.py b/src/nomad_simulations/schema_packages/properties/permittivity.py index 553dce5d..aeede940 100644 --- a/src/nomad_simulations/schema_packages/properties/permittivity.py +++ b/src/nomad_simulations/schema_packages/properties/permittivity.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from typing import TYPE_CHECKING, Optional import numpy as np diff --git a/src/nomad_simulations/schema_packages/properties/spectral_profile.py b/src/nomad_simulations/schema_packages/properties/spectral_profile.py index 2f086007..8078ff3d 100644 --- a/src/nomad_simulations/schema_packages/properties/spectral_profile.py +++ b/src/nomad_simulations/schema_packages/properties/spectral_profile.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from typing import TYPE_CHECKING, Optional import numpy as np @@ -109,7 +91,7 @@ def resolve_pdos_name(self, logger: 'BoundLogger') -> Optional[str]: Returns: (Optional[str]): The resolved `name` of the projected DOS profile. """ - if self.entity_ref is None: + if self.entity_ref is None and not self.name == 'ElectronicDensityOfStates': logger.warning( 'The `entity_ref` is not set for the DOS profile. Could not resolve the `name`.' ) diff --git a/src/nomad_simulations/schema_packages/properties/thermodynamics.py b/src/nomad_simulations/schema_packages/properties/thermodynamics.py index 0bcf9d7c..d6135943 100644 --- a/src/nomad_simulations/schema_packages/properties/thermodynamics.py +++ b/src/nomad_simulations/schema_packages/properties/thermodynamics.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from typing import TYPE_CHECKING import numpy as np diff --git a/src/nomad_simulations/schema_packages/utils/__init__.py b/src/nomad_simulations/schema_packages/utils/__init__.py index dc4e7ea4..52d9ca22 100644 --- a/src/nomad_simulations/schema_packages/utils/__init__.py +++ b/src/nomad_simulations/schema_packages/utils/__init__.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. -# See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - from .utils import ( RussellSaundersState, get_composition, diff --git a/src/nomad_simulations/schema_packages/utils/utils.py b/src/nomad_simulations/schema_packages/utils/utils.py index e925b53b..1d40aa4a 100644 --- a/src/nomad_simulations/schema_packages/utils/utils.py +++ b/src/nomad_simulations/schema_packages/utils/utils.py @@ -1,22 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. -# See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from math import factorial from typing import TYPE_CHECKING @@ -29,8 +10,6 @@ from nomad.datamodel.data import ArchiveSection from structlog.stdlib import BoundLogger - from nomad_simulations.schema_packages.model_system import Cell - configuration = config.get_plugin_entry_point( 'nomad_simulations.schema_packages:nomad_simulations_plugin' ) diff --git a/src/nomad_simulations/schema_packages/variables.py b/src/nomad_simulations/schema_packages/variables.py index ce02cfbb..34e3c8c4 100644 --- a/src/nomad_simulations/schema_packages/variables.py +++ b/src/nomad_simulations/schema_packages/variables.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from typing import TYPE_CHECKING, Optional import numpy as np diff --git a/tests/__init__.py b/tests/__init__.py index 52e83b1e..5cdfd197 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from nomad import utils logger = utils.get_logger(__name__) diff --git a/tests/conftest.py b/tests/conftest.py index 02c25e41..c68c036b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - import os from typing import Optional diff --git a/tests/properties/__init__.py b/tests/properties/__init__.py new file mode 100644 index 00000000..5cdfd197 --- /dev/null +++ b/tests/properties/__init__.py @@ -0,0 +1,3 @@ +from nomad import utils + +logger = utils.get_logger(__name__) diff --git a/tests/test_band_gap.py b/tests/properties/test_band_gap.py similarity index 85% rename from tests/test_band_gap.py rename to tests/properties/test_band_gap.py index 8d8a6b53..48939ea8 100644 --- a/tests/test_band_gap.py +++ b/tests/properties/test_band_gap.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from typing import Optional, Union import numpy as np diff --git a/tests/test_band_structure.py b/tests/properties/test_band_structure.py similarity index 94% rename from tests/test_band_structure.py rename to tests/properties/test_band_structure.py index 1e81aab5..e5de0c5a 100644 --- a/tests/test_band_structure.py +++ b/tests/properties/test_band_structure.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from typing import Optional import numpy as np @@ -24,8 +6,8 @@ from nomad_simulations.schema_packages.properties import ElectronicEigenvalues +from ..conftest import generate_electronic_eigenvalues from . import logger -from .conftest import generate_electronic_eigenvalues, generate_simulation class TestElectronicEigenvalues: diff --git a/tests/test_energies.py b/tests/properties/test_energies.py similarity index 79% rename from tests/test_energies.py rename to tests/properties/test_energies.py index 9f9dc01f..92ba8695 100644 --- a/tests/test_energies.py +++ b/tests/properties/test_energies.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from nomad_simulations.schema_packages.properties import ( FermiLevel, KineticEnergy, diff --git a/tests/test_fermi_surface.py b/tests/properties/test_fermi_surface.py similarity index 65% rename from tests/test_fermi_surface.py rename to tests/properties/test_fermi_surface.py index 05c7206b..c0d7d304 100644 --- a/tests/test_fermi_surface.py +++ b/tests/properties/test_fermi_surface.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from typing import Optional import pytest diff --git a/tests/properties/test_forces.py b/tests/properties/test_forces.py new file mode 100644 index 00000000..b260c3bc --- /dev/null +++ b/tests/properties/test_forces.py @@ -0,0 +1,17 @@ +from nomad_simulations.schema_packages.properties import TotalForce + + +class TestTotalForce: + """ + Test the `TotalForce` class defined in `properties/forces.py`. + """ + + # ! Include this initial `test_default_quantities` method when testing your PhysicalProperty classes + def test_default_quantities(self): + """ + Test the default quantities assigned when creating an instance of the `TotalForce` class. + """ + total_force = TotalForce() + # assert total_force.iri == 'http://fairmat-nfdi.eu/taxonomy/TotalForce' + assert total_force.name == 'TotalForce' + assert total_force.rank == [] diff --git a/tests/test_greens_function.py b/tests/properties/test_greens_function.py similarity index 89% rename from tests/test_greens_function.py rename to tests/properties/test_greens_function.py index 36b96222..b6335a4a 100644 --- a/tests/test_greens_function.py +++ b/tests/properties/test_greens_function.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from typing import Optional, Union import pytest diff --git a/tests/test_hopping_matrix.py b/tests/properties/test_hopping_matrix.py similarity index 79% rename from tests/test_hopping_matrix.py rename to tests/properties/test_hopping_matrix.py index b7cf43d7..e1a5a06e 100644 --- a/tests/test_hopping_matrix.py +++ b/tests/properties/test_hopping_matrix.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from typing import Optional import pytest diff --git a/tests/test_permittivity.py b/tests/properties/test_permittivity.py similarity index 88% rename from tests/test_permittivity.py rename to tests/properties/test_permittivity.py index f6955f97..cf6c0332 100644 --- a/tests/test_permittivity.py +++ b/tests/properties/test_permittivity.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from typing import Optional import numpy as np @@ -24,8 +6,8 @@ from nomad_simulations.schema_packages.properties import Permittivity from nomad_simulations.schema_packages.variables import Frequency, KMesh, Variables +from ..conftest import generate_k_space_simulation from . import logger -from .conftest import generate_k_space_simulation class TestPermittivity: diff --git a/tests/test_spectral_profile.py b/tests/properties/test_spectral_profile.py similarity index 94% rename from tests/test_spectral_profile.py rename to tests/properties/test_spectral_profile.py index 4184bbb7..38cb50ca 100644 --- a/tests/test_spectral_profile.py +++ b/tests/properties/test_spectral_profile.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from typing import Optional import numpy as np diff --git a/tests/test_atoms_state.py b/tests/test_atoms_state.py index dd2aa70c..081aa81f 100644 --- a/tests/test_atoms_state.py +++ b/tests/test_atoms_state.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from typing import Optional, Union import numpy as np diff --git a/tests/test_forces.py b/tests/test_forces.py deleted file mode 100644 index 234cab0d..00000000 --- a/tests/test_forces.py +++ /dev/null @@ -1,35 +0,0 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -from nomad_simulations.schema_packages.properties import TotalForce - - -class TestTotalForce: - """ - Test the `TotalForce` class defined in `properties/forces.py`. - """ - - # ! Include this initial `test_default_quantities` method when testing your PhysicalProperty classes - def test_default_quantities(self): - """ - Test the default quantities assigned when creating an instance of the `TotalForce` class. - """ - total_force = TotalForce() - # assert total_force.iri == 'http://fairmat-nfdi.eu/taxonomy/TotalForce' - assert total_force.name == 'TotalForce' - assert total_force.rank == [] diff --git a/tests/test_general.py b/tests/test_general.py index 06a360c9..a693f33c 100644 --- a/tests/test_general.py +++ b/tests/test_general.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - import numpy as np import pytest from nomad.datamodel import EntryArchive diff --git a/tests/test_model_method.py b/tests/test_model_method.py index 7e51e22d..6f6e6393 100644 --- a/tests/test_model_method.py +++ b/tests/test_model_method.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from typing import Optional import pytest diff --git a/tests/test_model_system.py b/tests/test_model_system.py index e189ace8..87ecd33b 100644 --- a/tests/test_model_system.py +++ b/tests/test_model_system.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from typing import Optional import numpy as np @@ -72,12 +54,11 @@ class TestCell: ), # different ordered positions but same cell ], ) - def test_eq_ne(self, cell_1: Cell, cell_2: Cell, result: bool): + def test_is_equal_cell(self, cell_1: Cell, cell_2: Cell, result: bool): """ - Test the `__eq__` and `__ne__` operator functions of `Cell`. + Test the `is_equal_cell` methods of `Cell`. """ - assert (cell_1 == cell_2) == result - assert (cell_1 != cell_2) != result + assert cell_1.is_equal_cell(other=cell_2) == result class TestAtomicCell: @@ -184,12 +165,11 @@ class TestAtomicCell: ), # different ordered positions but same chemical symbols ], ) - def test_eq_ne(self, cell_1: Cell, cell_2: Cell, result: bool): + def test_is_equal_cell(self, cell_1: Cell, cell_2: Cell, result: bool): """ - Test the `__eq__` and `__ne__` operator functions of `AtomicCell`. + Test the `is_equal_cell` methods of `AtomicCell`. """ - assert (cell_1 == cell_2) == result - assert (cell_1 != cell_2) != result + assert cell_1.is_equal_cell(other=cell_2) == result @pytest.mark.parametrize( 'chemical_symbols, atomic_numbers, formula, lattice_vectors, positions, periodic_boundary_conditions', diff --git a/tests/test_numerical_settings.py b/tests/test_numerical_settings.py index 70ab30da..6426b4cd 100644 --- a/tests/test_numerical_settings.py +++ b/tests/test_numerical_settings.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from typing import Optional import numpy as np diff --git a/tests/test_outputs.py b/tests/test_outputs.py index a048b8ec..ba9d8149 100644 --- a/tests/test_outputs.py +++ b/tests/test_outputs.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from typing import Optional import pytest diff --git a/tests/test_physical_properties.py b/tests/test_physical_properties.py index b9e9e1bf..02ad7f7a 100644 --- a/tests/test_physical_properties.py +++ b/tests/test_physical_properties.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - from typing import Optional, Union import numpy as np diff --git a/tests/test_variables.py b/tests/test_variables.py index c64faf91..f9fc3312 100644 --- a/tests/test_variables.py +++ b/tests/test_variables.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - import pytest from nomad.datamodel import EntryArchive diff --git a/tests/utils/__init__.py b/tests/utils/__init__.py new file mode 100644 index 00000000..5cdfd197 --- /dev/null +++ b/tests/utils/__init__.py @@ -0,0 +1,3 @@ +from nomad import utils + +logger = utils.get_logger(__name__) diff --git a/tests/test_utils.py b/tests/utils/test_utils.py similarity index 81% rename from tests/test_utils.py rename to tests/utils/test_utils.py index 26f8a5d4..a50978f6 100644 --- a/tests/test_utils.py +++ b/tests/utils/test_utils.py @@ -1,21 +1,3 @@ -# -# Copyright The NOMAD Authors. -# -# This file is part of NOMAD. See https://nomad-lab.eu for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - import pytest from nomad_simulations.schema_packages.model_system import (