From 45273421184add30438d660e6e6b36976c038157 Mon Sep 17 00:00:00 2001 From: "Jose M. Pizarro" <112697669+JosePizarro3@users.noreply.github.com> Date: Thu, 15 Aug 2024 16:01:12 +0200 Subject: [PATCH] Allowing 3.11 python version (#107) * Adding Python 3.10 and 3.11 to package and actions Add env system for uv installation * Moved out coveralls testing to its own action * Updated publishing adding python versions 3.10 and 3.11 * Fix pytest action * Updated readme * Fixed errors Using plural for properties under Outputs * Fix ruff --- .github/workflows/actions.yml | 52 ++-- .github/workflows/coveralls.yml | 44 +++ .github/workflows/publish.yml | 26 +- README.md | 4 +- pyproject.toml | 5 + .../schema_packages/outputs.py | 10 +- .../schema_packages/properties/energies.py | 12 + .../schema_packages/utils/utils.py | 5 +- tests/conftest.py | 1 + tests/test_atoms_state.py | 1 + tests/test_band_gap.py | 4 +- tests/test_band_structure.py | 35 +-- tests/test_energies.py | 6 +- tests/test_fermi_surface.py | 1 + tests/test_forces.py | 2 +- tests/test_general.py | 1 + tests/test_hopping_matrix.py | 1 + tests/test_model_method.py | 1 + tests/test_model_system.py | 1 + tests/test_numerical_settings.py | 2 +- tests/test_outputs.py | 8 +- tests/test_permittivity.py | 1 + tests/test_physical_properties.py | 1 + tests/test_spectral_profile.py | 1 + tests/test_thermodynamics.py | 283 ------------------ tests/test_utils.py | 1 + tests/test_variables.py | 1 + 27 files changed, 139 insertions(+), 371 deletions(-) create mode 100644 .github/workflows/coveralls.yml delete mode 100644 tests/test_thermodynamics.py diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 9d753ef4..6aad546a 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -1,4 +1,4 @@ -name: install-and-test +name: Installing and Testing on: [push] # https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs @@ -9,55 +9,57 @@ permissions: checks: write pull-requests: write +env: + UV_SYSTEM_PYTHON: true + jobs: install-and-test: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python_version: ["3.9", "3.10", "3.11"] steps: - uses: actions/checkout@v4 - - name: Set up Python 3.9 + - name: Set up Python ${{matrix.python_version}} uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: ${{matrix.python_version}} + - name: Install uv + run: | + curl -LsSf https://astral.sh/uv/install.sh | sh - name: Install dependencies run: | pip install --upgrade pip - pip install uv - uv pip install -e '.[dev]' --index-url https://gitlab.mpcdf.mpg.de/api/v4/projects/2187/packages/pypi/simple --system - uv pip install coveralls --system + uv pip install -e '.[dev]' - name: mypy run: | python -m mypy --ignore-missing-imports --follow-imports=silent --no-strict-optional src/nomad_simulations/schema_packages tests - - name: Build coverage file + - name: Test with pytest run: | - pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=src tests | tee pytest-coverage.txt - - name: Pytest coverage comment - uses: MishaKav/pytest-coverage-comment@main - with: - pytest-coverage-path: pytest-coverage.txt - junitxml-path: pytest.xml - - name: Submit to coveralls - continue-on-error: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - coveralls --service=github + python -m pytest -sv tests build-and-install: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python_version: ["3.9", "3.10", "3.11"] steps: - uses: actions/checkout@v4 - - name: Set up Python 3.9 + - name: Set up Python ${{matrix.python_version}} uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: ${{matrix.python_version}} + - name: Install uv + run: | + curl -LsSf https://astral.sh/uv/install.sh | sh - name: Build the package run: | - pip install uv - uv pip install --upgrade pip --system - uv pip install build --system + uv pip install build python -m build --sdist - name: Install the package run: | - uv pip install dist/*.tar.gz --index-url https://gitlab.mpcdf.mpg.de/api/v4/projects/2187/packages/pypi/simple --system + uv pip install dist/*.tar.gz ruff-linting: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/coveralls.yml b/.github/workflows/coveralls.yml new file mode 100644 index 00000000..36984819 --- /dev/null +++ b/.github/workflows/coveralls.yml @@ -0,0 +1,44 @@ +name: Testing with coveralls Report +on: [push] + +# https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs +# `contents` is for permission to the contents of the repository. +# `pull-requests` is for permission to pull request +permissions: + contents: write + checks: write + pull-requests: write + +env: + UV_SYSTEM_PYTHON: true + +jobs: + coveralls-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.11 + uses: actions/setup-python@v5 + with: + python-version: 3.11 + - name: Install uv + run: | + curl -LsSf https://astral.sh/uv/install.sh | sh + - name: Install dependencies + run: | + uv pip install -e '.[dev]' + uv pip install coveralls + - name: Build coverage file + run: | + pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=src tests | tee pytest-coverage.txt + - name: Pytest coverage comment + uses: MishaKav/pytest-coverage-comment@main + with: + pytest-coverage-path: pytest-coverage.txt + junitxml-path: pytest.xml + - name: Submit to coveralls + continue-on-error: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + coveralls --service=github diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d4e46753..a37ef1d2 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -15,27 +15,31 @@ on: permissions: contents: read +env: + UV_SYSTEM_PYTHON: true + jobs: deploy: - runs-on: ubuntu-latest - + strategy: + fail-fast: false + matrix: + python_version: ["3.9", "3.10", "3.11"] steps: - - uses: actions/checkout@v3 - - - name: Set up Python 3.9 - uses: actions/setup-python@v3 + - uses: actions/checkout@v4 + - name: Set up Python ${{matrix.python_version}} + uses: actions/setup-python@v5 with: - python-version: '3.9' - + python-version: ${{matrix.python_version}} + - name: Install uv + run: | + curl -LsSf https://astral.sh/uv/install.sh | sh - name: Install dependencies run: | pip install --upgrade pip - pip install build - + uv pip install build - name: Build package run: python -m build - - name: Publish package to PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: diff --git a/README.md b/README.md index cd27b270..db79a566 100644 --- a/README.md +++ b/README.md @@ -20,11 +20,11 @@ pip install nomad-simulations --index-url https://gitlab.mpcdf.mpg.de/api/v4/pro ## Development -If you want to develop locally this package, clone the project and in the workspace folder, create a virtual environment (note this project uses Python 3.9): +If you want to develop locally this package, clone the project and in the workspace folder, create a virtual environment (you can use Python 3.9, 3.10, or 3.11): ```sh git clone https://github.com/nomad-coe/nomad-simulations.git cd nomad-simulations -python3.9 -m venv .pyenv +python3.11 -m venv .pyenv . .pyenv/bin/activate ``` diff --git a/pyproject.toml b/pyproject.toml index 825e1608..117c62f6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,6 +8,8 @@ classifiers = [ "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", "License :: OSI Approved :: Apache Software License", ] name = "nomad-simulations" @@ -46,6 +48,9 @@ dev = [ "structlog", ] +[tool.uv] +index-url = "https://gitlab.mpcdf.mpg.de/api/v4/projects/2187/packages/pypi/simple" + [tool.ruff] # Exclude a variety of commonly ignored directories. exclude = [ diff --git a/src/nomad_simulations/schema_packages/outputs.py b/src/nomad_simulations/schema_packages/outputs.py index 313ddbf9..5d3896fb 100644 --- a/src/nomad_simulations/schema_packages/outputs.py +++ b/src/nomad_simulations/schema_packages/outputs.py @@ -118,15 +118,15 @@ class Outputs(ArchiveSection): xas_spectra = SubSection(sub_section=XASSpectrum.m_def, repeats=True) - total_energy = SubSection(sub_section=TotalEnergy.m_def, repeats=True) + total_energies = SubSection(sub_section=TotalEnergy.m_def, repeats=True) - kinetic_energy = SubSection(sub_section=KineticEnergy.m_def, repeats=True) + kinetic_energies = SubSection(sub_section=KineticEnergy.m_def, repeats=True) - potential_energy = SubSection(sub_section=PotentialEnergy.m_def, repeats=True) + potential_energies = SubSection(sub_section=PotentialEnergy.m_def, repeats=True) - total_force = SubSection(sub_section=TotalForce.m_def, repeats=True) + total_forces = SubSection(sub_section=TotalForce.m_def, repeats=True) - temperature = SubSection(sub_section=Temperature.m_def, repeats=True) + temperatures = SubSection(sub_section=Temperature.m_def, repeats=True) # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # diff --git a/src/nomad_simulations/schema_packages/properties/energies.py b/src/nomad_simulations/schema_packages/properties/energies.py index 6355133a..7ab68fe7 100644 --- a/src/nomad_simulations/schema_packages/properties/energies.py +++ b/src/nomad_simulations/schema_packages/properties/energies.py @@ -127,6 +127,12 @@ class KineticEnergy(BaseEnergy): Physical property section describing the kinetic energy of a (sub)system. """ + def __init__( + self, m_def: 'Section' = None, m_context: 'Context' = None, **kwargs + ) -> None: + super().__init__(m_def, m_context, **kwargs) + self.name = self.m_def.name + def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None: super().normalize(archive, logger) @@ -136,5 +142,11 @@ class PotentialEnergy(BaseEnergy): Physical property section describing the potential energy of a (sub)system. """ + def __init__( + self, m_def: 'Section' = None, m_context: 'Context' = None, **kwargs + ) -> None: + super().__init__(m_def, m_context, **kwargs) + self.name = self.m_def.name + def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None: super().normalize(archive, logger) diff --git a/src/nomad_simulations/schema_packages/utils/utils.py b/src/nomad_simulations/schema_packages/utils/utils.py index 3a4acdbb..ac5ee561 100644 --- a/src/nomad_simulations/schema_packages/utils/utils.py +++ b/src/nomad_simulations/schema_packages/utils/utils.py @@ -111,8 +111,9 @@ def multiplicity(self): @property def degeneracy(self): - return factorial(self.multiplicity) / ( - factorial(self.multiplicity - self.occupation) * factorial(self.occupation) + return factorial(int(self.multiplicity)) / ( + factorial(int(self.multiplicity - self.occupation)) + * factorial(self.occupation) ) diff --git a/tests/conftest.py b/tests/conftest.py index c4a5a798..097298c2 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -23,6 +23,7 @@ import pytest from nomad.datamodel import EntryArchive from nomad.units import ureg + from nomad_simulations.schema_packages.atoms_state import AtomsState, OrbitalsState from nomad_simulations.schema_packages.general import Simulation from nomad_simulations.schema_packages.model_method import ModelMethod diff --git a/tests/test_atoms_state.py b/tests/test_atoms_state.py index 65a1e3d0..dd2aa70c 100644 --- a/tests/test_atoms_state.py +++ b/tests/test_atoms_state.py @@ -22,6 +22,7 @@ import pytest from nomad.datamodel import EntryArchive from nomad.units import ureg + from nomad_simulations.schema_packages.atoms_state import ( AtomsState, CoreHole, diff --git a/tests/test_band_gap.py b/tests/test_band_gap.py index 20688217..8d8a6b53 100644 --- a/tests/test_band_gap.py +++ b/tests/test_band_gap.py @@ -22,6 +22,7 @@ import pytest from nomad.datamodel import EntryArchive from nomad.units import ureg + from nomad_simulations.schema_packages.properties import ElectronicBandGap from nomad_simulations.schema_packages.variables import Temperature @@ -78,9 +79,6 @@ def test_validate_values(self, value: Union[list[float], float], result: float): (None, None, None), (None, 'direct', 'direct'), (None, 'indirect', 'indirect'), - ([], None, None), - ([], 'direct', 'direct'), - ([], 'indirect', 'indirect'), ([[0, 0, 0]], None, None), ([[0, 0, 0]], 'direct', None), ([[0, 0, 0]], 'indirect', None), diff --git a/tests/test_band_structure.py b/tests/test_band_structure.py index 2e410112..1e81aab5 100644 --- a/tests/test_band_structure.py +++ b/tests/test_band_structure.py @@ -21,6 +21,7 @@ import numpy as np import pytest from nomad.datamodel import EntryArchive + from nomad_simulations.schema_packages.properties import ElectronicEigenvalues from . import logger @@ -91,12 +92,6 @@ def test_default_quantities(self, n_bands: Optional[int], rank: Optional[list]): False, (None, None), ), - ( - [], - [[3, -2], [3, 1], [4, -2], [5, -1], [4, 0], [2, 0], [2, 1], [4, -3]], - False, - (None, None), - ), ( [[2, 2], [0, 0]], [[3, -2], [3, 1], [4, -2], [5, -1], [4, 0], [2, 0], [2, 1], [4, -3]], @@ -188,13 +183,6 @@ def test_order_eigenvalues( None, (None, None), ), - ( - [], - [[3, -2], [3, 1], [4, -2], [5, -1], [4, 0], [2, 0], [2, 1], [4, -3]], - None, - None, - (None, None), - ), ( [[2, 2], [0, 0]], [[3, -2], [3, 1], [4, -2], [5, -1], [4, 0], [2, 0], [2, 1], [4, -3]], @@ -217,13 +205,6 @@ def test_order_eigenvalues( 2.0, (1.0, 2.0), ), - ( - [], - [[3, -2], [3, 1], [4, -2], [5, -1], [4, 0], [2, 0], [2, 1], [4, -3]], - 1.0, - 2.0, - (1.0, 2.0), - ), ( [[2, 2], [0, 0]], [[3, -2], [3, 1], [4, -2], [5, -1], [4, 0], [2, 0], [2, 1], [4, -3]], @@ -290,13 +271,6 @@ def test_homo_lumo_eigenvalues( None, None, ), - ( - [], - [[3, -2], [3, 1], [4, -2], [5, -1], [4, 0], [2, 0], [2, 1], [4, -3]], - None, - None, - None, - ), ( [[2, 2], [0, 0]], [[3, -2], [3, 1], [4, -2], [5, -1], [4, 0], [2, 0], [2, 1], [4, -3]], @@ -319,13 +293,6 @@ def test_homo_lumo_eigenvalues( 2.0, 1.0, ), - ( - [], - [[3, -2], [3, 1], [4, -2], [5, -1], [4, 0], [2, 0], [2, 1], [4, -3]], - 1.0, - 2.0, - 1.0, - ), ( [[2, 2], [0, 0]], [[3, -2], [3, 1], [4, -2], [5, -1], [4, 0], [2, 0], [2, 1], [4, -3]], diff --git a/tests/test_energies.py b/tests/test_energies.py index 589242c4..9f9dc01f 100644 --- a/tests/test_energies.py +++ b/tests/test_energies.py @@ -51,7 +51,7 @@ def test_default_quantities(self): Test the default quantities assigned when creating an instance of the `TotalEnergy` class. """ total_energy = TotalEnergy() - assert total_energy.iri == 'http://fairmat-nfdi.eu/taxonomy/TotalEnergy' + # assert total_energy.iri == 'http://fairmat-nfdi.eu/taxonomy/TotalEnergy' assert total_energy.name == 'TotalEnergy' assert total_energy.rank == [] @@ -67,7 +67,7 @@ def test_default_quantities(self): Test the default quantities assigned when creating an instance of the `KineticEnergy` class. """ kinetic_energy = KineticEnergy() - assert kinetic_energy.iri == 'http://fairmat-nfdi.eu/taxonomy/KineticEnergy' + # assert kinetic_energy.iri == 'http://fairmat-nfdi.eu/taxonomy/KineticEnergy' assert kinetic_energy.name == 'KineticEnergy' assert kinetic_energy.rank == [] @@ -83,6 +83,6 @@ def test_default_quantities(self): Test the default quantities assigned when creating an instance of the `PotentialEnergy` class. """ potential_energy = PotentialEnergy() - assert potential_energy.iri == 'http://fairmat-nfdi.eu/taxonomy/PotentialEnergy' + # assert potential_energy.iri == 'http://fairmat-nfdi.eu/taxonomy/PotentialEnergy' assert potential_energy.name == 'PotentialEnergy' assert potential_energy.rank == [] diff --git a/tests/test_fermi_surface.py b/tests/test_fermi_surface.py index dde4ce1f..05c7206b 100644 --- a/tests/test_fermi_surface.py +++ b/tests/test_fermi_surface.py @@ -19,6 +19,7 @@ from typing import Optional import pytest + from nomad_simulations.schema_packages.properties import FermiSurface diff --git a/tests/test_forces.py b/tests/test_forces.py index c172bb6d..234cab0d 100644 --- a/tests/test_forces.py +++ b/tests/test_forces.py @@ -30,6 +30,6 @@ 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.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 e722e03e..06a360c9 100644 --- a/tests/test_general.py +++ b/tests/test_general.py @@ -19,6 +19,7 @@ import numpy as np import pytest from nomad.datamodel import EntryArchive + from nomad_simulations.schema_packages.general import Simulation from nomad_simulations.schema_packages.model_system import ( AtomicCell, diff --git a/tests/test_hopping_matrix.py b/tests/test_hopping_matrix.py index cfe6ada2..b7cf43d7 100644 --- a/tests/test_hopping_matrix.py +++ b/tests/test_hopping_matrix.py @@ -19,6 +19,7 @@ from typing import Optional import pytest + from nomad_simulations.schema_packages.properties import ( CrystalFieldSplitting, HoppingMatrix, diff --git a/tests/test_model_method.py b/tests/test_model_method.py index b66c5e25..7e51e22d 100644 --- a/tests/test_model_method.py +++ b/tests/test_model_method.py @@ -20,6 +20,7 @@ import pytest from nomad.datamodel import EntryArchive + from nomad_simulations.schema_packages.atoms_state import AtomsState, OrbitalsState from nomad_simulations.schema_packages.general import Simulation from nomad_simulations.schema_packages.model_method import ( diff --git a/tests/test_model_system.py b/tests/test_model_system.py index ecb67a76..6ead47e8 100644 --- a/tests/test_model_system.py +++ b/tests/test_model_system.py @@ -21,6 +21,7 @@ import numpy as np import pytest from nomad.datamodel import EntryArchive + from nomad_simulations.schema_packages.model_system import ( ChemicalFormula, ModelSystem, diff --git a/tests/test_numerical_settings.py b/tests/test_numerical_settings.py index 966d2651..70ab30da 100644 --- a/tests/test_numerical_settings.py +++ b/tests/test_numerical_settings.py @@ -22,6 +22,7 @@ import pytest from nomad.datamodel import EntryArchive from nomad.units import ureg + from nomad_simulations.schema_packages.numerical_settings import ( KLinePath, KMesh, @@ -289,7 +290,6 @@ class TestKLinePath: 'high_symmetry_path_names, high_symmetry_path_values, result', [ (None, None, False), - ([], [], False), (['Gamma', 'X', 'Y'], None, False), ([], [[0, 0, 0], [0.5, 0, 0], [0, 0.5, 0]], False), (['Gamma', 'X', 'Y'], [[0, 0, 0], [0.5, 0, 0], [0, 0.5, 0]], True), diff --git a/tests/test_outputs.py b/tests/test_outputs.py index 73eef906..9aaee9c4 100644 --- a/tests/test_outputs.py +++ b/tests/test_outputs.py @@ -20,6 +20,7 @@ import pytest from nomad.datamodel import EntryArchive + from nomad_simulations.schema_packages.model_method import ModelMethod from nomad_simulations.schema_packages.model_system import ModelSystem from nomad_simulations.schema_packages.numerical_settings import SelfConsistency @@ -41,7 +42,7 @@ def test_number_of_properties(self): which properties are already defined and in which order to control their normalizations """ outputs = Outputs() - assert len(outputs.m_def.all_sub_sections) == 12 + assert len(outputs.m_def.all_sub_sections) == 17 defined_properties = [ 'fermi_levels', 'chemical_potentials', @@ -55,6 +56,11 @@ def test_number_of_properties(self): 'permittivities', 'absorption_spectra', 'xas_spectra', + 'total_energies', + 'kinetic_energies', + 'potential_energies', + 'total_forces', + 'temperatures', ] assert list(outputs.m_def.all_sub_sections.keys()) == defined_properties diff --git a/tests/test_permittivity.py b/tests/test_permittivity.py index 9cb58fbc..f6955f97 100644 --- a/tests/test_permittivity.py +++ b/tests/test_permittivity.py @@ -20,6 +20,7 @@ import numpy as np import pytest + from nomad_simulations.schema_packages.properties import Permittivity from nomad_simulations.schema_packages.variables import Frequency, KMesh, Variables diff --git a/tests/test_physical_properties.py b/tests/test_physical_properties.py index 12191221..b9e9e1bf 100644 --- a/tests/test_physical_properties.py +++ b/tests/test_physical_properties.py @@ -23,6 +23,7 @@ from nomad.datamodel import EntryArchive from nomad.metainfo import Quantity from nomad.units import ureg + from nomad_simulations.schema_packages.physical_property import ( PhysicalProperty, validate_quantity_wrt_value, diff --git a/tests/test_spectral_profile.py b/tests/test_spectral_profile.py index 003bd029..4184bbb7 100644 --- a/tests/test_spectral_profile.py +++ b/tests/test_spectral_profile.py @@ -22,6 +22,7 @@ import pytest from nomad.datamodel import EntryArchive from nomad.units import ureg + from nomad_simulations.schema_packages.atoms_state import AtomsState from nomad_simulations.schema_packages.general import Simulation from nomad_simulations.schema_packages.model_system import AtomicCell, ModelSystem diff --git a/tests/test_thermodynamics.py b/tests/test_thermodynamics.py deleted file mode 100644 index 1fe9c842..00000000 --- a/tests/test_thermodynamics.py +++ /dev/null @@ -1,283 +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 ( - ChemicalPotential, - Enthalpy, - Entropy, - GibbsFreeEnergy, - Heat, - HeatCapacity, - HelmholtzFreeEnergy, - Hessian, - InternalEnergy, - MassDensity, - Pressure, - Temperature, - VirialTensor, - Volume, - Work, -) - - -class TestPressure: - """ - Test the `Pressure` class defined in `properties/thermodynamics.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 `Pressure` class. - """ - pressure = Pressure() - assert pressure.iri == 'http://fairmat-nfdi.eu/taxonomy/Pressure' - assert pressure.name == 'Pressure' - assert pressure.rank == [] - - -class TestVolume: - """ - Test the `Volume` class defined in `properties/thermodynamics.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 `Volume` class. - """ - volume = Volume() - assert volume.iri == 'http://fairmat-nfdi.eu/taxonomy/Volume' - assert volume.name == 'Volume' - assert volume.rank == [] - - -class TestTemperature: - """ - Test the `Temperature` class defined in `properties/thermodynamics.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 `Temperature` class. - """ - temperature = Temperature() - assert temperature.iri == 'http://fairmat-nfdi.eu/taxonomy/Temperature' - assert temperature.name == 'Temperature' - assert temperature.rank == [] - - -class TestHeat: - """ - Test the `Heat` class defined in `properties/thermodynamics.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 `Heat` class. - """ - heat = Heat() - assert heat.iri == 'http://fairmat-nfdi.eu/taxonomy/Heat' - assert heat.name == 'Heat' - assert heat.rank == [] - - -class TestWork: - """ - Test the `Work` class defined in `properties/thermodynamics.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 `Work` class. - """ - work = Work() - assert work.iri == 'http://fairmat-nfdi.eu/taxonomy/Work' - assert work.name == 'Work' - assert work.rank == [] - - -class TestInternalEnergy: - """ - Test the `InternalEnergy` class defined in `properties/thermodynamics.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 `InternalEnergy` class. - """ - internal_energy = InternalEnergy() - assert internal_energy.iri == 'http://fairmat-nfdi.eu/taxonomy/InternalEnergy' - assert internal_energy.name == 'InternalEnergy' - assert internal_energy.rank == [] - - -class TestEnthalpy: - """ - Test the `Enthalpy` class defined in `properties/thermodynamics.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 `Enthalpy` class. - """ - enthalpy = Enthalpy() - assert enthalpy.iri == 'http://fairmat-nfdi.eu/taxonomy/Enthalpy' - assert enthalpy.name == 'Enthalpy' - assert enthalpy.rank == [] - - -class TestEntropy: - """ - Test the `Entropy` class defined in `properties/thermodynamics.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 `Entropy` class. - """ - entropy = Entropy() - assert entropy.iri == 'http://fairmat-nfdi.eu/taxonomy/Entropy' - assert entropy.name == 'Entropy' - assert entropy.rank == [] - - -class TestGibbsFreeEnergy: - """ - Test the `GibbsFreeEnergy` class defined in `properties/thermodynamics.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 `GibbsFreeEnergy` class. - """ - gibbs_free_energy = GibbsFreeEnergy() - assert ( - gibbs_free_energy.iri == 'http://fairmat-nfdi.eu/taxonomy/GibbsFreeEnergy' - ) - assert gibbs_free_energy.name == 'GibbsFreeEnergy' - assert gibbs_free_energy.rank == [] - - -class TestHelmholtzFreeEnergy: - """ - Test the `HelmholtzFreeEnergy` class defined in `properties/thermodynamics.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 `HelmholtzFreeEnergy` class. - """ - helmholtz_free_energy = HelmholtzFreeEnergy() - assert ( - helmholtz_free_energy.iri - == 'http://fairmat-nfdi.eu/taxonomy/HelmholtzFreeEnergy' - ) - assert helmholtz_free_energy.name == 'HelmholtzFreeEnergy' - assert helmholtz_free_energy.rank == [] - - -class TestChemicalPotential: - """ - Test the `ChemicalPotential` class defined in `properties/thermodynamics.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 `ChemicalPotential` class. - """ - chemical_potential = ChemicalPotential() - assert ( - chemical_potential.iri - == 'http://fairmat-nfdi.eu/taxonomy/ChemicalPotential' - ) - assert chemical_potential.name == 'ChemicalPotential' - assert chemical_potential.rank == [] - - -class TestHeatCapacity: - """ - Test the `HeatCapacity` class defined in `properties/thermodynamics.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 `HeatCapacity` class. - """ - heat_capacity = HeatCapacity() - assert heat_capacity.iri == 'http://fairmat-nfdi.eu/taxonomy/HeatCapacity' - assert heat_capacity.name == 'HeatCapacity' - assert heat_capacity.rank == [] - - -class TestVirialTensor: - """ - Test the `VirialTensor` class defined in `properties/thermodynamics.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 `VirialTensor` class. - """ - virial_tensor = VirialTensor() - assert virial_tensor.iri == 'http://fairmat-nfdi.eu/taxonomy/VirialTensor' - assert virial_tensor.name == 'VirialTensor' - assert virial_tensor.rank == [] - - -class TestMassDensity: - """ - Test the `MassDensity` class defined in `properties/thermodynamics.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 `MassDensity` class. - """ - mass_density = MassDensity() - assert mass_density.iri == 'http://fairmat-nfdi.eu/taxonomy/MassDensity' - assert mass_density.name == 'MassDensity' - assert mass_density.rank == [] - - -class TestHessian: - """ - Test the `Hessian` class defined in `properties/thermodynamics.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 `Hessian` class. - """ - hessian = Hessian() - assert hessian.iri == 'http://fairmat-nfdi.eu/taxonomy/Hessian' - assert hessian.name == 'Hessian' - assert hessian.rank == [] diff --git a/tests/test_utils.py b/tests/test_utils.py index 8cf7512a..3d3e69cf 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -17,6 +17,7 @@ # import pytest + from nomad_simulations.schema_packages.model_system import ( AtomicCell, ModelSystem, diff --git a/tests/test_variables.py b/tests/test_variables.py index 2fd63a00..c64faf91 100644 --- a/tests/test_variables.py +++ b/tests/test_variables.py @@ -18,6 +18,7 @@ import pytest from nomad.datamodel import EntryArchive + from nomad_simulations.schema_packages.variables import Variables from . import logger