diff --git a/.vscode/settings.json b/.vscode/settings.json index 04985fcd..0c8648fb 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,6 +7,10 @@ "files.trimTrailingWhitespace": true, "[python]": { "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.fixAll": "explicit", + "source.organizeImports": "explicit" + }, "editor.defaultFormatter": "charliermarsh.ruff" }, "python.testing.pytestArgs": [ diff --git a/pyproject.toml b/pyproject.toml index d9d5d0ef..825e1608 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -81,6 +81,9 @@ select = [ "E", # pycodestyle "W", # pycodestyle "PL", # pylint + "F", # Pyflakes + "UP", # pyupgrade + "I", # isort ] ignore = [ @@ -88,6 +91,7 @@ ignore = [ "E701", # Multiple statements on one line (colon) "E731", # Do not assign a lambda expression, use a def "E402", # Module level import not at top of file + "F401", "PLR0911", # Too many return statements "PLR0912", # Too many branches "PLR0913", # Too many arguments in function definition diff --git a/src/nomad_simulations/schema_packages/atoms_state.py b/src/nomad_simulations/schema_packages/atoms_state.py index c091fa35..72ddb2f3 100644 --- a/src/nomad_simulations/schema_packages/atoms_state.py +++ b/src/nomad_simulations/schema_packages/atoms_state.py @@ -16,12 +16,11 @@ # limitations under the License. # -from typing import TYPE_CHECKING, Any, Dict, Optional, Union +from typing import TYPE_CHECKING, Any, Optional, Union import ase import numpy as np import pint - from nomad.datamodel.data import ArchiveSection from nomad.datamodel.metainfo.annotations import ELNAnnotation from nomad.datamodel.metainfo.basesections import Entity @@ -29,8 +28,8 @@ from nomad.units import ureg if TYPE_CHECKING: - from nomad.metainfo import Section, Context from nomad.datamodel.datamodel import EntryArchive + from nomad.metainfo import Context, Section from structlog.stdlib import BoundLogger from nomad_simulations.schema_packages.utils import RussellSaundersState @@ -154,7 +153,7 @@ def __init__(self, m_def: 'Section' = None, m_context: 'Context' = None, **kwarg ) ), } - self._orbitals_map: Dict[str, Any] = { + self._orbitals_map: dict[str, Any] = { 'l_symbols': self._orbitals[-1], 'ml_symbols': {i: self._orbitals[i] for i in range(4)}, 'ms_symbols': dict(zip((-0.5, 0.5), ('down', 'up'))), diff --git a/src/nomad_simulations/schema_packages/general.py b/src/nomad_simulations/schema_packages/general.py index 9f5e8127..2e126221 100644 --- a/src/nomad_simulations/schema_packages/general.py +++ b/src/nomad_simulations/schema_packages/general.py @@ -16,10 +16,9 @@ # limitations under the License. # -from typing import TYPE_CHECKING, List +from typing import TYPE_CHECKING import numpy as np - from nomad.config import config from nomad.datamodel.data import Schema from nomad.datamodel.metainfo.annotations import ELNAnnotation @@ -204,15 +203,15 @@ def resolve_composition_formula(self, system_parent: ModelSystem) -> None: """ def set_composition_formula( - system: ModelSystem, subsystems: List[ModelSystem], atom_labels: List[str] + system: ModelSystem, subsystems: list[ModelSystem], atom_labels: list[str] ) -> None: """Determine the composition formula for `system` based on its `subsystems`. If `system` has no children, the atom_labels are used to determine the formula. Args: system (ModelSystem): The system under consideration. - subsystems (List[ModelSystem]): The children of system. - atom_labels (List[str]): The global list of atom labels corresponding + subsystems (list[ModelSystem]): The children of system. + atom_labels (list[str]): The global list of atom labels corresponding to the atom indices stored in system. """ if not subsystems: @@ -236,13 +235,13 @@ def set_composition_formula( children_names=subsystem_labels ) - def get_composition_recurs(system: ModelSystem, atom_labels: List[str]) -> None: + def get_composition_recurs(system: ModelSystem, atom_labels: list[str]) -> None: """Traverse the system hierarchy downward and set the branch composition for all (sub)systems at each level. Args: system (ModelSystem): The system to traverse downward. - atom_labels (List[str]): The global list of atom labels corresponding + atom_labels (list[str]): The global list of atom labels corresponding to the atom indices stored in system. """ subsystems = system.model_system diff --git a/src/nomad_simulations/schema_packages/model_method.py b/src/nomad_simulations/schema_packages/model_method.py index e2c9ac79..96839a9d 100644 --- a/src/nomad_simulations/schema_packages/model_method.py +++ b/src/nomad_simulations/schema_packages/model_method.py @@ -17,17 +17,16 @@ # import re -from typing import TYPE_CHECKING, List, Optional +from typing import TYPE_CHECKING, Optional import numpy as np - from nomad.datamodel.data import ArchiveSection from nomad.datamodel.metainfo.annotations import ELNAnnotation -from nomad.metainfo import MEnum, Quantity, SubSection, URL, Section +from nomad.metainfo import URL, MEnum, Quantity, Section, SubSection if TYPE_CHECKING: - from nomad.metainfo import Context from nomad.datamodel.datamodel import EntryArchive + from nomad.metainfo import Context from structlog.stdlib import BoundLogger from nomad_simulations.schema_packages.atoms_state import CoreHole, OrbitalsState @@ -302,16 +301,16 @@ def __init__(self, m_def: 'Section' = None, m_context: 'Context' = None, **kwarg } def resolve_libxc_names( - self, xc_functionals: List[XCFunctional] - ) -> Optional[List[str]]: + self, xc_functionals: list[XCFunctional] + ) -> Optional[list[str]]: """ Resolves the `libxc_names` and sorts them from the list of `XCFunctional` sections. Args: - xc_functionals (List[XCFunctional]): The list of `XCFunctional` sections. + xc_functionals (list[XCFunctional]): The list of `XCFunctional` sections. Returns: - (Optional[List[str]]): The resolved and sorted `libxc_names`. + (Optional[list[str]]): The resolved and sorted `libxc_names`. """ return sorted( [ @@ -323,13 +322,13 @@ def resolve_libxc_names( def resolve_jacobs_ladder( self, - libxc_names: List[str], + libxc_names: list[str], ) -> str: """ Resolves the `jacobs_ladder` from the `libxc_names`. The mapping (libxc -> NOMAD) is set in `self._jacobs_ladder_map`. Args: - libxc_names (List[str]): The list of `libxc_names`. + libxc_names (list[str]): The list of `libxc_names`. Returns: (str): The resolved `jacobs_ladder`. @@ -356,14 +355,14 @@ def resolve_jacobs_ladder( return self._jacobs_ladder_map.get(highest_rung_abbrev, 'unavailable') def resolve_exact_exchange_mixing_factor( - self, xc_functionals: List[XCFunctional], libxc_names: List[str] + self, xc_functionals: list[XCFunctional], libxc_names: list[str] ) -> Optional[float]: """ Resolves the `exact_exchange_mixing_factor` from the `xc_functionals` and `libxc_names`. Args: - xc_functionals (List[XCFunctional]): The list of `XCFunctional` sections. - libxc_names (List[str]): The list of `libxc_names`. + xc_functionals (list[XCFunctional]): The list of `XCFunctional` sections. + libxc_names (list[str]): The list of `libxc_names`. Returns: (Optional[float]): The resolved `exact_exchange_mixing_factor`. @@ -373,7 +372,7 @@ def resolve_exact_exchange_mixing_factor( if functional.name == 'hybrid': return functional.parameters.get('exact_exchange_mixing_factor') - def _scan_patterns(patterns: List[str], xc_name: str) -> bool: + def _scan_patterns(patterns: list[str], xc_name: str) -> bool: return any(x for x in patterns if re.search('_' + x + '$', xc_name)) for xc_name in libxc_names: @@ -496,20 +495,20 @@ def resolve_type(self) -> Optional[str]: def resolve_orbital_references( self, - model_systems: List[ModelSystem], + model_systems: list[ModelSystem], logger: 'BoundLogger', model_index: int = -1, - ) -> Optional[List[OrbitalsState]]: + ) -> Optional[list[OrbitalsState]]: """ Resolves the references to the `OrbitalsState` sections from the child `ModelSystem` section. Args: - model_systems (List[ModelSystem]): The list of `ModelSystem` sections. + model_systems (list[ModelSystem]): The list of `ModelSystem` sections. logger (BoundLogger): The logger to log messages. model_index (int, optional): The `ModelSystem` section index from which resolve the references. Defaults to -1. Returns: - Optional[List[OrbitalsState]]: The resolved references to the `OrbitalsState` sections. + Optional[list[OrbitalsState]]: The resolved references to the `OrbitalsState` sections. """ try: model_system = model_systems[model_index] diff --git a/src/nomad_simulations/schema_packages/model_system.py b/src/nomad_simulations/schema_packages/model_system.py index 8dc21cb5..70c26649 100644 --- a/src/nomad_simulations/schema_packages/model_system.py +++ b/src/nomad_simulations/schema_packages/model_system.py @@ -17,11 +17,10 @@ # import re -from typing import TYPE_CHECKING, Optional, Tuple +from typing import TYPE_CHECKING, Optional import ase import numpy as np - from matid import Classifier, SymmetryAnalyzer # pylint: disable=import-error from matid.classification.classifications import ( Atom, @@ -32,9 +31,8 @@ Material2D, Surface, ) - -from nomad.config import config from nomad.atomutils import Formula, get_normalized_wyckoff, search_aflow_prototype +from nomad.config import config from nomad.datamodel.data import ArchiveSection from nomad.datamodel.metainfo.annotations import ELNAnnotation from nomad.datamodel.metainfo.basesections import Entity, System @@ -42,8 +40,8 @@ from nomad.units import ureg if TYPE_CHECKING: - from nomad.metainfo import Section, Context from nomad.datamodel.datamodel import EntryArchive + from nomad.metainfo import Context, Section from structlog.stdlib import BoundLogger from nomad_simulations.schema_packages.atoms_state import AtomsState @@ -541,7 +539,7 @@ def resolve_analyzed_atomic_cell( def resolve_bulk_symmetry( self, original_atomic_cell: AtomicCell, logger: 'BoundLogger' - ) -> Tuple[Optional[AtomicCell], Optional[AtomicCell]]: + ) -> tuple[Optional[AtomicCell], Optional[AtomicCell]]: """ Resolves the symmetry of the material being simulated using MatID and the originally parsed data under original_atomic_cell. It generates two other @@ -553,8 +551,7 @@ def resolve_bulk_symmetry( uses to in MatID.SymmetryAnalyzer(). logger (BoundLogger): The logger to log messages. Returns: - primitive_atomic_cell (Optional[AtomicCell]): The primitive `AtomicCell` section. - conventional_atomic_cell (Optional[AtomicCell]): The standarized `AtomicCell` section. + primitive_atomic_cell, conventional_atomic_cell (tuple[Optional[AtomicCell], Optional[AtomicCell]]): The primitive and standardized `AtomicCell` sections. """ symmetry = {} try: @@ -945,7 +942,7 @@ class ModelSystem(System): def resolve_system_type_and_dimensionality( self, ase_atoms: ase.Atoms, logger: 'BoundLogger' - ) -> Tuple[str, int]: + ) -> tuple[str, int]: """ Resolves the `ModelSystem.type` and `ModelSystem.dimensionality` using `MatID` classification analyzer: @@ -954,8 +951,7 @@ def resolve_system_type_and_dimensionality( Args: ase.Atoms: The ASE Atoms structure to analyse. Returns: - system_type (str): The system type as determined by MatID. - dimensionality (str): The system dimensionality as determined by MatID. + system_type, dimensionality (tuple[str]): The system type and dimensionality as determined by MatID. """ classification = None system_type, dimensionality = self.type, self.dimensionality diff --git a/src/nomad_simulations/schema_packages/numerical_settings.py b/src/nomad_simulations/schema_packages/numerical_settings.py index 480201c2..71d3eb27 100644 --- a/src/nomad_simulations/schema_packages/numerical_settings.py +++ b/src/nomad_simulations/schema_packages/numerical_settings.py @@ -17,20 +17,18 @@ # from itertools import accumulate, chain, tee -from typing import TYPE_CHECKING, List, Optional, Tuple, Union +from typing import TYPE_CHECKING, Optional, Union import numpy as np import pint - from ase.dft.kpoints import get_monkhorst_pack_size_and_offset, monkhorst_pack - from nomad.datamodel.data import ArchiveSection from nomad.metainfo import JSON, MEnum, Quantity, SubSection from nomad.units import ureg if TYPE_CHECKING: - from nomad.metainfo import Section, Context from nomad.datamodel.datamodel import EntryArchive + from nomad.metainfo import Context, Section from structlog.stdlib import BoundLogger from nomad_simulations.schema_packages.model_system import ModelSystem @@ -176,7 +174,7 @@ def validate_reciprocal_lattice_vectors( reciprocal_lattice_vectors: Optional[pint.Quantity], logger: 'BoundLogger', check_grid: Optional[bool] = False, - grid: Optional[List[int]] = [], + grid: Optional[list[int]] = [], ) -> bool: """ Validate the `reciprocal_lattice_vectors` by checking if they exist and if they have the same dimensionality as `grid`. @@ -185,7 +183,7 @@ def validate_reciprocal_lattice_vectors( reciprocal_lattice_vectors (Optional[pint.Quantity]): The reciprocal lattice vectors of the atomic cell. logger (BoundLogger): The logger to log messages. check_grid (bool, optional): Flag to check the `grid` is set to True. Defaults to False. - grid (Optional[List[int]], optional): The grid of the `KMesh`. Defaults to []. + grid (Optional[list[int]], optional): The grid of the `KMesh`. Defaults to []. Returns: (bool): True if the `reciprocal_lattice_vectors` exist. If `check_grid_too` is set to True, it also checks if the @@ -211,7 +209,7 @@ def validate_reciprocal_lattice_vectors( def resolve_high_symmetry_points( self, - model_systems: List[ModelSystem], + model_systems: list[ModelSystem], logger: 'BoundLogger', eps: float = 3e-3, ) -> Optional[dict]: @@ -221,7 +219,7 @@ def resolve_high_symmetry_points( special (high symmetry) points information. Args: - model_systems (List[ModelSystem]): The list of `ModelSystem` sections. + model_systems (list[ModelSystem]): The list of `ModelSystem` sections. logger (BoundLogger): The logger to log messages. eps (float, optional): Tolerance factor to define the `lattice` ASE object. Defaults to 3e-3. @@ -364,7 +362,7 @@ class KMesh(Mesh): def resolve_points_and_offset( self, logger: 'BoundLogger' - ) -> Tuple[Optional[List[np.ndarray]], Optional[np.ndarray]]: + ) -> tuple[Optional[list[np.ndarray]], Optional[np.ndarray]]: """ Resolves the `points` and `offset` of the `KMesh` from the `grid` and the `center`. @@ -372,7 +370,7 @@ def resolve_points_and_offset( logger (BoundLogger): The logger to log messages. Returns: - (Optional[List[pint.Quantity, pint.Quantity]]): The resolved `points` and `offset` of the `KMesh`. + (tuple[Optional[list[np.ndarray]], Optional[np.ndarray]]): The resolved `points` and `offset` of the `KMesh`. """ if self.grid is None: logger.warning('Could not find `KMesh.grid`.') @@ -429,7 +427,7 @@ def get_k_line_density( def resolve_k_line_density( self, - model_systems: List[ModelSystem], + model_systems: list[ModelSystem], reciprocal_lattice_vectors: pint.Quantity, logger: 'BoundLogger', ) -> Optional[pint.Quantity]: @@ -437,7 +435,7 @@ def resolve_k_line_density( Resolves the `k_line_density` of the `KMesh` from the the list of `ModelSystem`. Args: - model_systems (List[ModelSystem]): The list of `ModelSystem` sections. + model_systems (list[ModelSystem]): The list of `ModelSystem` sections. logger (BoundLogger): The logger to log messages. Returns: @@ -545,20 +543,20 @@ class KLinePath(ArchiveSection): def resolve_high_symmetry_path_values( self, - model_systems: List[ModelSystem], + model_systems: list[ModelSystem], reciprocal_lattice_vectors: pint.Quantity, logger: 'BoundLogger', - ) -> Optional[List[float]]: + ) -> Optional[list[float]]: """ Resolves the `high_symmetry_path_values` of the `KLinePath` from the `high_symmetry_path_names`. Args: - model_systems (List[ModelSystem]): The list of `ModelSystem` sections. + model_systems (list[ModelSystem]): The list of `ModelSystem` sections. reciprocal_lattice_vectors (pint.Quantity): The reciprocal lattice vectors of the atomic cell. logger (BoundLogger): The logger to log messages. Returns: - (Optional[List[float]]): The resolved `high_symmetry_path_values`. + (Optional[list[float]]): The resolved `high_symmetry_path_values`. """ # Initial check on the `reciprocal_lattice_vectors` if not KSpaceFunctionalities().validate_reciprocal_lattice_vectors( @@ -616,7 +614,7 @@ def get_high_symmetry_path_norms( self, reciprocal_lattice_vectors: Optional[pint.Quantity], logger: 'BoundLogger', - ) -> Optional[List[pint.Quantity]]: + ) -> Optional[list[pint.Quantity]]: """ Get the high symmetry path points norms from the list of dictionaries of vectors in units of the `reciprocal_lattice_vectors`. The norms are accummulated, such that the first high symmetry point in the path list has a norm of 0, while the others sum the @@ -628,7 +626,7 @@ def get_high_symmetry_path_norms( logger (BoundLogger): The logger to log messages. Returns: - (Optional[List[pint.Quantity]]): The high symmetry points norms list, e.g. in a cubic lattice: + (Optional[list[pint.Quantity]]): The high symmetry points norms list, e.g. in a cubic lattice: `high_symmetry_path_value_norms = [0, 0.5, 0.5 + 1 / np.sqrt(2), 1 + 1 / np.sqrt(2)]` """ # Checking the high symmetry path quantities @@ -666,7 +664,7 @@ def calc_norms( def resolve_points( self, - points_norm: Union[np.ndarray, List[float]], + points_norm: Union[np.ndarray, list[float]], reciprocal_lattice_vectors: Optional[np.ndarray], logger: 'BoundLogger', ) -> None: @@ -675,7 +673,7 @@ def resolve_points( when a list of points norms and the list of dictionaries of the high symmetry path are passed to resolve the `KLinePath.points`. Args: - points_norm (List[float]): List of points norms in the k-line path. + points_norm (list[float]): List of points norms in the k-line path. reciprocal_lattice_vectors (Optional[np.ndarray]): The reciprocal lattice vectors of the atomic cell. logger (BoundLogger): The logger to log messages. """ @@ -797,13 +795,13 @@ def __init__(self, m_def: 'Section' = None, m_context: 'Context' = None, **kwarg self.name = self.m_def.name def resolve_reciprocal_lattice_vectors( - self, model_systems: List[ModelSystem], logger: 'BoundLogger' + self, model_systems: list[ModelSystem], logger: 'BoundLogger' ) -> Optional[pint.Quantity]: """ Resolve the `reciprocal_lattice_vectors` of the `KSpace` from the representative `ModelSystem` section. Args: - model_systems (List[ModelSystem]): The list of `ModelSystem` sections. + model_systems (list[ModelSystem]): The list of `ModelSystem` sections. logger (BoundLogger): The logger to log messages. Returns: diff --git a/src/nomad_simulations/schema_packages/outputs.py b/src/nomad_simulations/schema_packages/outputs.py index 3c7c9a1e..313ddbf9 100644 --- a/src/nomad_simulations/schema_packages/outputs.py +++ b/src/nomad_simulations/schema_packages/outputs.py @@ -16,9 +16,9 @@ # limitations under the License. # -import numpy as np -from typing import TYPE_CHECKING, List, Optional +from typing import TYPE_CHECKING, Optional +import numpy as np from nomad.datamodel.data import ArchiveSection from nomad.datamodel.metainfo.annotations import ELNAnnotation from nomad.metainfo import Quantity, SubSection @@ -27,8 +27,8 @@ from nomad.datamodel.datamodel import EntryArchive from structlog.stdlib import BoundLogger -from nomad_simulations.schema_packages.model_system import ModelSystem 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 from nomad_simulations.schema_packages.physical_property import PhysicalProperty from nomad_simulations.schema_packages.properties import ( @@ -42,13 +42,13 @@ FermiLevel, FermiSurface, HoppingMatrix, - Permittivity, - XASSpectrum, - TotalEnergy, KineticEnergy, + Permittivity, PotentialEnergy, - TotalForce, Temperature, + TotalEnergy, + TotalForce, + XASSpectrum, ) @@ -133,7 +133,7 @@ class Outputs(ArchiveSection): def extract_spin_polarized_property( self, property_name: str - ) -> List[PhysicalProperty]: + ) -> list[PhysicalProperty]: """ Extracts the spin-polarized properties if present from the property name and returns them as a list of two elements in which each element refers to each `spin_channel`. If the return list is empty, it means that the simulation is not @@ -143,7 +143,7 @@ def extract_spin_polarized_property( property_name (str): The name of the property to be extracted. Returns: - (List[PhysicalProperty]): The list of spin-polarized properties. + (list[PhysicalProperty]): The list of spin-polarized properties. """ spin_polarized_properties = [] properties = getattr(self, property_name) @@ -213,7 +213,7 @@ class SCFOutputs(Outputs): def get_last_scf_steps_value( self, - scf_last_steps: List[Outputs], + scf_last_steps: list[Outputs], property_name: str, i_property: int, scf_parameters: Optional[SelfConsistency], @@ -223,7 +223,7 @@ def get_last_scf_steps_value( Get the last two SCF values' magnitudes of a physical property and appends then in a list. Args: - scf_last_steps (List[Outputs]): The list of SCF steps. This must be of length 2 in order to the method to work. + scf_last_steps (list[Outputs]): The list of SCF steps. This must be of length 2 in order to the method to work. property_name (str): The name of the physical property. i_property (int): The index of the physical property. scf_parameters (Optional[SelfConsistency]): The self-consistency parameters section stored under `ModelMethod`. diff --git a/src/nomad_simulations/schema_packages/physical_property.py b/src/nomad_simulations/schema_packages/physical_property.py index 5d1ab622..af478fc0 100644 --- a/src/nomad_simulations/schema_packages/physical_property.py +++ b/src/nomad_simulations/schema_packages/physical_property.py @@ -20,11 +20,10 @@ from typing import TYPE_CHECKING, Any, Optional import numpy as np - from nomad import utils from nomad.datamodel.data import ArchiveSection -from nomad.datamodel.metainfo.basesections import Entity from nomad.datamodel.metainfo.annotations import ELNAnnotation +from nomad.datamodel.metainfo.basesections import Entity from nomad.metainfo import ( URL, MEnum, @@ -36,13 +35,13 @@ from nomad.metainfo.metainfo import Dimension, DirectQuantity, _placeholder_quantity if TYPE_CHECKING: - from nomad.metainfo import Section, Context from nomad.datamodel.datamodel import EntryArchive + from nomad.metainfo import Context, Section from structlog.stdlib import BoundLogger +from nomad_simulations.schema_packages.model_method import BaseModelMethod from nomad_simulations.schema_packages.numerical_settings import SelfConsistency from nomad_simulations.schema_packages.variables import Variables -from nomad_simulations.schema_packages.model_method import BaseModelMethod # We add `logger` for the `validate_quantity_wrt_value` decorator logger = utils.get_logger(__name__) diff --git a/src/nomad_simulations/schema_packages/properties/__init__.py b/src/nomad_simulations/schema_packages/properties/__init__.py index a4042294..59b31d0b 100644 --- a/src/nomad_simulations/schema_packages/properties/__init__.py +++ b/src/nomad_simulations/schema_packages/properties/__init__.py @@ -19,31 +19,14 @@ from .band_gap import ElectronicBandGap from .band_structure import ElectronicBandStructure, ElectronicEigenvalues from .energies import ( - FermiLevel, EnergyContribution, - TotalEnergy, + FermiLevel, KineticEnergy, PotentialEnergy, -) -from .forces import BaseForce, ForceContribution, TotalForce -from .thermodynamics import ( - Pressure, - Volume, - Temperature, - Heat, - Work, - InternalEnergy, - Enthalpy, - Entropy, - GibbsFreeEnergy, - HelmholtzFreeEnergy, - ChemicalPotential, - HeatCapacity, - VirialTensor, - MassDensity, - Hessian, + TotalEnergy, ) from .fermi_surface import FermiSurface +from .forces import BaseForce, ForceContribution, TotalForce from .hopping_matrix import CrystalFieldSplitting, HoppingMatrix from .permittivity import Permittivity from .spectral_profile import ( @@ -53,3 +36,20 @@ SpectralProfile, XASSpectrum, ) +from .thermodynamics import ( + ChemicalPotential, + Enthalpy, + Entropy, + GibbsFreeEnergy, + Heat, + HeatCapacity, + HelmholtzFreeEnergy, + Hessian, + InternalEnergy, + MassDensity, + Pressure, + Temperature, + VirialTensor, + Volume, + Work, +) diff --git a/src/nomad_simulations/schema_packages/properties/band_gap.py b/src/nomad_simulations/schema_packages/properties/band_gap.py index 35b83d32..ee7c12dd 100644 --- a/src/nomad_simulations/schema_packages/properties/band_gap.py +++ b/src/nomad_simulations/schema_packages/properties/band_gap.py @@ -20,12 +20,11 @@ import numpy as np import pint - from nomad.metainfo import MEnum, Quantity if TYPE_CHECKING: - from nomad.metainfo import Section, Context from nomad.datamodel.datamodel import EntryArchive + from nomad.metainfo import Context, Section from structlog.stdlib import BoundLogger from nomad_simulations.schema_packages.physical_property import PhysicalProperty diff --git a/src/nomad_simulations/schema_packages/properties/band_structure.py b/src/nomad_simulations/schema_packages/properties/band_structure.py index 5bb887ed..59560fc0 100644 --- a/src/nomad_simulations/schema_packages/properties/band_structure.py +++ b/src/nomad_simulations/schema_packages/properties/band_structure.py @@ -16,17 +16,16 @@ # limitations under the License. # -from typing import TYPE_CHECKING, Optional, Tuple, Union +from typing import TYPE_CHECKING, Optional, Union import numpy as np import pint - from nomad.config import config from nomad.metainfo import Quantity, SubSection if TYPE_CHECKING: - from nomad.metainfo import Section, Context from nomad.datamodel.datamodel import EntryArchive + from nomad.metainfo import Context, Section from structlog.stdlib import BoundLogger from nomad_simulations.schema_packages.numerical_settings import KSpace @@ -150,13 +149,13 @@ def __init__( self.name = self.m_def.name @validate_quantity_wrt_value(name='occupation') - def order_eigenvalues(self) -> Union[bool, Tuple[pint.Quantity, np.ndarray]]: + def order_eigenvalues(self) -> Union[bool, tuple[pint.Quantity, np.ndarray]]: """ Order the eigenvalues based on the `value` and `occupation`. The return `value` and `occupation` are flattened. Returns: - (Union[bool, Tuple[pint.Quantity, np.ndarray]]): The flattened and sorted `value` and `occupation`. If validation + (Union[bool, tuple[pint.Quantity, np.ndarray]]): The flattened and sorted `value` and `occupation`. If validation fails, then it returns `False`. """ total_shape = np.prod(self.value.shape) @@ -178,14 +177,14 @@ def order_eigenvalues(self) -> Union[bool, Tuple[pint.Quantity, np.ndarray]]: def resolve_homo_lumo_eigenvalues( self, - ) -> Tuple[Optional[pint.Quantity], Optional[pint.Quantity]]: + ) -> tuple[Optional[pint.Quantity], Optional[pint.Quantity]]: """ Resolve the `highest_occupied` and `lowest_unoccupied` eigenvalues by performing a binary search on the flattened and sorted `value` and `occupation`. If these quantities already exist, overwrite them or return them if it is not possible to resolve from `value` and `occupation`. Returns: - (Tuple[Optional[pint.Quantity], Optional[pint.Quantity]]): The `highest_occupied` and + (tuple[Optional[pint.Quantity], Optional[pint.Quantity]]): The `highest_occupied` and `lowest_unoccupied` eigenvalues. """ # Sorting `value` and `occupation` diff --git a/src/nomad_simulations/schema_packages/properties/energies.py b/src/nomad_simulations/schema_packages/properties/energies.py index d31f3f09..6355133a 100644 --- a/src/nomad_simulations/schema_packages/properties/energies.py +++ b/src/nomad_simulations/schema_packages/properties/energies.py @@ -19,12 +19,11 @@ from typing import TYPE_CHECKING import numpy as np - -from nomad.metainfo import Quantity, Section, Context, SubSection +from nomad.metainfo import Context, Quantity, Section, SubSection if TYPE_CHECKING: - from nomad.metainfo import Section, Context from nomad.datamodel.datamodel import EntryArchive + from nomad.metainfo import Context, Section from structlog.stdlib import BoundLogger from nomad_simulations.schema_packages.physical_property import ( diff --git a/src/nomad_simulations/schema_packages/properties/fermi_surface.py b/src/nomad_simulations/schema_packages/properties/fermi_surface.py index b4c8edc4..9829bff0 100644 --- a/src/nomad_simulations/schema_packages/properties/fermi_surface.py +++ b/src/nomad_simulations/schema_packages/properties/fermi_surface.py @@ -19,12 +19,11 @@ from typing import TYPE_CHECKING import numpy as np - from nomad.metainfo import Quantity if TYPE_CHECKING: - from nomad.metainfo import Section, Context from nomad.datamodel.datamodel import EntryArchive + from nomad.metainfo import Context, Section from structlog.stdlib import BoundLogger from nomad_simulations.schema_packages.physical_property import PhysicalProperty diff --git a/src/nomad_simulations/schema_packages/properties/forces.py b/src/nomad_simulations/schema_packages/properties/forces.py index 0ce7b945..b47048f6 100644 --- a/src/nomad_simulations/schema_packages/properties/forces.py +++ b/src/nomad_simulations/schema_packages/properties/forces.py @@ -20,12 +20,11 @@ from typing import TYPE_CHECKING import numpy as np - -from nomad.metainfo import Quantity, Section, Context, SubSection +from nomad.metainfo import Context, Quantity, Section, SubSection if TYPE_CHECKING: - from nomad.metainfo import Section, Context from nomad.datamodel.datamodel import EntryArchive + from nomad.metainfo import Context, Section from structlog.stdlib import BoundLogger from nomad_simulations.schema_packages.physical_property import ( diff --git a/src/nomad_simulations/schema_packages/properties/hopping_matrix.py b/src/nomad_simulations/schema_packages/properties/hopping_matrix.py index cc2aae19..699f866e 100644 --- a/src/nomad_simulations/schema_packages/properties/hopping_matrix.py +++ b/src/nomad_simulations/schema_packages/properties/hopping_matrix.py @@ -19,12 +19,11 @@ from typing import TYPE_CHECKING import numpy as np - from nomad.metainfo import Quantity if TYPE_CHECKING: - from nomad.metainfo import Section, Context from nomad.datamodel.datamodel import EntryArchive + from nomad.metainfo import Context, Section from structlog.stdlib import BoundLogger from nomad_simulations.schema_packages.physical_property import PhysicalProperty diff --git a/src/nomad_simulations/schema_packages/properties/permittivity.py b/src/nomad_simulations/schema_packages/properties/permittivity.py index 5776a0aa..553dce5d 100644 --- a/src/nomad_simulations/schema_packages/properties/permittivity.py +++ b/src/nomad_simulations/schema_packages/properties/permittivity.py @@ -16,15 +16,14 @@ # limitations under the License. # -from typing import TYPE_CHECKING, List, Optional +from typing import TYPE_CHECKING, Optional import numpy as np - -from nomad.metainfo import Quantity, MEnum +from nomad.metainfo import MEnum, Quantity if TYPE_CHECKING: - from nomad.metainfo import Section, Context from nomad.datamodel.datamodel import EntryArchive + from nomad.metainfo import Context, Section from structlog.stdlib import BoundLogger from nomad_simulations.schema_packages.physical_property import PhysicalProperty @@ -82,7 +81,7 @@ def resolve_type(self) -> str: def extract_absorption_spectra( self, logger: 'BoundLogger' - ) -> Optional[List[AbsorptionSpectrum]]: + ) -> Optional[list[AbsorptionSpectrum]]: """ Extract the absorption spectrum from the imaginary part of the permittivity tensor. """ diff --git a/src/nomad_simulations/schema_packages/properties/spectral_profile.py b/src/nomad_simulations/schema_packages/properties/spectral_profile.py index 2ea5c932..2f086007 100644 --- a/src/nomad_simulations/schema_packages/properties/spectral_profile.py +++ b/src/nomad_simulations/schema_packages/properties/spectral_profile.py @@ -16,17 +16,16 @@ # limitations under the License. # -from typing import TYPE_CHECKING, Dict, List, Optional +from typing import TYPE_CHECKING, Optional import numpy as np import pint - from nomad.config import config from nomad.metainfo import MEnum, Quantity, SubSection if TYPE_CHECKING: - from nomad.metainfo import Section, Context from nomad.datamodel.datamodel import EntryArchive + from nomad.metainfo import Context, Section from structlog.stdlib import BoundLogger from nomad_simulations.schema_packages.atoms_state import AtomsState, OrbitalsState @@ -388,7 +387,7 @@ def extract_band_gap(self) -> Optional[ElectronicBandGap]: def extract_projected_dos( self, type: str, logger: 'BoundLogger' - ) -> List[Optional[DOSProfile]]: + ) -> list[Optional[DOSProfile]]: """ Extract the projected DOS from the `projected_dos` section and the specified `type`. @@ -448,7 +447,7 @@ def generate_from_projected_dos( # Extract `atom_projected` from `orbital_projected` by summing up the `orbital_projected` contributions for each atom if len(atom_projected) == 0: - atom_data: Dict[AtomsState, List[DOSProfile]] = {} + atom_data: dict[AtomsState, list[DOSProfile]] = {} for orb_pdos in orbital_projected: # `entity_ref` is the `OrbitalsState` section, whose parent is `AtomsState` entity_ref = orb_pdos.entity_ref.m_parent diff --git a/src/nomad_simulations/schema_packages/properties/thermodynamics.py b/src/nomad_simulations/schema_packages/properties/thermodynamics.py index 5d0c4c03..0bcf9d7c 100644 --- a/src/nomad_simulations/schema_packages/properties/thermodynamics.py +++ b/src/nomad_simulations/schema_packages/properties/thermodynamics.py @@ -19,12 +19,11 @@ from typing import TYPE_CHECKING import numpy as np - from nomad.metainfo import Quantity if TYPE_CHECKING: - from nomad.metainfo import Section, Context from nomad.datamodel.datamodel import EntryArchive + from nomad.metainfo import Context, Section from structlog.stdlib import BoundLogger from nomad_simulations.schema_packages.physical_property import PhysicalProperty diff --git a/src/nomad_simulations/schema_packages/utils/utils.py b/src/nomad_simulations/schema_packages/utils/utils.py index 6c1ec42b..3a4acdbb 100644 --- a/src/nomad_simulations/schema_packages/utils/utils.py +++ b/src/nomad_simulations/schema_packages/utils/utils.py @@ -23,7 +23,8 @@ import numpy as np if TYPE_CHECKING: - from typing import List, Optional + from typing import Optional + from nomad.datamodel.data import ArchiveSection from structlog.stdlib import BoundLogger @@ -136,17 +137,17 @@ def is_not_representative(model_system, logger: 'BoundLogger'): # cannot define typing with `Variables` due to circular import issue def get_variables( - variables: 'Optional[List[ArchiveSection]]', variable_cls: 'ArchiveSection' -) -> 'List[ArchiveSection]': + variables: 'Optional[list[ArchiveSection]]', variable_cls: 'ArchiveSection' +) -> 'list[ArchiveSection]': """ Get the list of variables which are of type `variable_cls` and appear under `variables`. Args: - variables (Optional[List[Variables]]): The list of variables to check. + variables (Optional[list[Variables]]): The list of variables to check. variable_cls (Variables): The class of the variables to get. Returns: - (List[Variables]): The list of variables which are of type `variable_cls`. + (list[Variables]): The list of variables which are of type `variable_cls`. """ if variables is None: return [] @@ -158,7 +159,7 @@ def get_variables( # TODO remove function in nomad.atomutils -def get_composition(children_names: 'List[str]') -> str: +def get_composition(children_names: 'list[str]') -> str: """ Generates a generalized "chemical formula" based on the provided list `children_names`, with the format X(m)Y(n) for children_names X and Y of quantities m and n, respectively. diff --git a/src/nomad_simulations/schema_packages/variables.py b/src/nomad_simulations/schema_packages/variables.py index 9736fd85..7ca3ef27 100644 --- a/src/nomad_simulations/schema_packages/variables.py +++ b/src/nomad_simulations/schema_packages/variables.py @@ -19,17 +19,18 @@ from typing import TYPE_CHECKING, Optional import numpy as np - from nomad.datamodel.data import ArchiveSection from nomad.metainfo import Quantity if TYPE_CHECKING: - from nomad.metainfo import Section, Context from nomad.datamodel.datamodel import EntryArchive + from nomad.metainfo import Context, Section from structlog.stdlib import BoundLogger from nomad_simulations.schema_packages.numerical_settings import ( KLinePath as KLinePathSettings, +) +from nomad_simulations.schema_packages.numerical_settings import ( KMesh as KMeshSettings, ) diff --git a/tests/__init__.py b/tests/__init__.py index 8176ffc0..52e83b1e 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -18,5 +18,4 @@ from nomad import utils - logger = utils.get_logger(__name__) diff --git a/tests/conftest.py b/tests/conftest.py index ec513a82..c4a5a798 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -17,31 +17,35 @@ # import os +from typing import Optional + import numpy as np import pytest -from typing import List, Optional - -from nomad.units import ureg from nomad.datamodel import EntryArchive - -from nomad_simulations.schema_packages.general import Simulation -from nomad_simulations.schema_packages.model_system import ModelSystem, AtomicCell +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 +from nomad_simulations.schema_packages.model_system import AtomicCell, ModelSystem from nomad_simulations.schema_packages.numerical_settings import ( - SelfConsistency, - KSpace, - KMesh as KMeshSettings, KLinePath as KLinePathSettings, ) +from nomad_simulations.schema_packages.numerical_settings import ( + KMesh as KMeshSettings, +) +from nomad_simulations.schema_packages.numerical_settings import ( + KSpace, + SelfConsistency, +) from nomad_simulations.schema_packages.outputs import Outputs, SCFOutputs -from nomad_simulations.schema_packages.variables import Energy2 as Energy, KLinePath from nomad_simulations.schema_packages.properties import ( - ElectronicBandGap, DOSProfile, + ElectronicBandGap, ElectronicDensityOfStates, ElectronicEigenvalues, ) +from nomad_simulations.schema_packages.variables import Energy2 as Energy +from nomad_simulations.schema_packages.variables import KLinePath from . import logger @@ -79,12 +83,12 @@ def generate_simulation( def generate_model_system( type: str = 'original', system_type: str = 'bulk', - positions: List[List[float]] = [[0, 0, 0], [0.5, 0.5, 0.5]], - lattice_vectors: List[List[float]] = [[1, 0, 0], [0, 1, 0], [0, 0, 1]], - chemical_symbols: List[str] = ['Ga', 'As'], - orbitals_symbols: List[List[str]] = [['s'], ['px', 'py']], + positions: list[list[float]] = [[0, 0, 0], [0.5, 0.5, 0.5]], + lattice_vectors: list[list[float]] = [[1, 0, 0], [0, 1, 0], [0, 0, 1]], + chemical_symbols: list[str] = ['Ga', 'As'], + orbitals_symbols: list[list[str]] = [['s'], ['px', 'py']], is_representative: bool = True, - pbc: List[bool] = [False, False, False], + pbc: list[bool] = [False, False, False], ) -> Optional[ModelSystem]: """ Generate a `ModelSystem` section with the given parameters. @@ -120,11 +124,11 @@ def generate_model_system( def generate_atomic_cell( - lattice_vectors: List[List[float]] = [[1, 0, 0], [0, 1, 0], [0, 0, 1]], + lattice_vectors: list[list[float]] = [[1, 0, 0], [0, 1, 0], [0, 0, 1]], positions: Optional[list] = None, - periodic_boundary_conditions: List[bool] = [False, False, False], - chemical_symbols: List[str] = ['H', 'H', 'O'], - atomic_numbers: List[int] = [1, 1, 8], + periodic_boundary_conditions: list[bool] = [False, False, False], + chemical_symbols: list[str] = ['H', 'H', 'O'], + atomic_numbers: list[int] = [1, 1, 8], ) -> AtomicCell: """ Generate an `AtomicCell` section with the given parameters. @@ -192,7 +196,7 @@ def generate_scf_electronic_band_gap_template( def generate_simulation_electronic_dos( - energy_points: List[int] = [-3, -2, -1, 0, 1, 2, 3], + energy_points: list[int] = [-3, -2, -1, 0, 1, 2, 3], ) -> Simulation: """ Generate a `Simulation` section with an `ElectronicDensityOfStates` section under `Outputs`. It uses @@ -232,8 +236,8 @@ def generate_simulation_electronic_dos( def generate_k_line_path( - high_symmetry_path_names: List[str] = ['Gamma', 'X', 'Y', 'Gamma'], - high_symmetry_path_values: List[List[float]] = [ + high_symmetry_path_names: list[str] = ['Gamma', 'X', 'Y', 'Gamma'], + high_symmetry_path_values: list[list[float]] = [ [0, 0, 0], [0.5, 0, 0], [0, 0.5, 0], @@ -249,24 +253,24 @@ def generate_k_line_path( def generate_k_space_simulation( system_type: str = 'bulk', is_representative: bool = True, - positions: List[List[float]] = [[0, 0, 0], [0.5, 0.5, 0.5]], - lattice_vectors: List[List[float]] = [[1, 0, 0], [0, 1, 0], [0, 0, 1]], - chemical_symbols: List[str] = ['Ga', 'As'], - orbitals_symbols: List[List[str]] = [['s'], ['px', 'py']], - pbc: List[bool] = [False, False, False], - reciprocal_lattice_vectors: Optional[List[List[float]]] = [ + positions: list[list[float]] = [[0, 0, 0], [0.5, 0.5, 0.5]], + lattice_vectors: list[list[float]] = [[1, 0, 0], [0, 1, 0], [0, 0, 1]], + chemical_symbols: list[str] = ['Ga', 'As'], + orbitals_symbols: list[list[str]] = [['s'], ['px', 'py']], + pbc: list[bool] = [False, False, False], + reciprocal_lattice_vectors: Optional[list[list[float]]] = [ [1, 0, 0], [0, 1, 0], [0, 0, 1], ], - high_symmetry_path_names: List[str] = ['Gamma', 'X', 'Y', 'Gamma'], - high_symmetry_path_values: List[List[float]] = [ + high_symmetry_path_names: list[str] = ['Gamma', 'X', 'Y', 'Gamma'], + high_symmetry_path_values: list[list[float]] = [ [0, 0, 0], [0.5, 0, 0], [0, 0.5, 0], [0, 0, 0], ], - klinepath_points: Optional[List[float]] = None, + klinepath_points: Optional[list[float]] = None, grid=[6, 6, 6], ) -> Simulation: model_system = generate_model_system( @@ -302,7 +306,7 @@ def generate_k_space_simulation( def generate_electronic_eigenvalues( - reciprocal_lattice_vectors: Optional[List[List[float]]] = [ + reciprocal_lattice_vectors: Optional[list[list[float]]] = [ [1, 0, 0], [0, 1, 0], [0, 0, 1], @@ -351,7 +355,7 @@ def generate_electronic_eigenvalues( model_method = ModelMethod(numerical_settings=[k_space]) if reciprocal_lattice_vectors is not None and len(reciprocal_lattice_vectors) > 0: k_space.reciprocal_lattice_vectors = reciprocal_lattice_vectors - simulation = generate_simulation( + _ = generate_simulation( model_system=generate_model_system(), model_method=model_method, outputs=outputs, diff --git a/tests/test_atoms_state.py b/tests/test_atoms_state.py index 92fe9e70..65a1e3d0 100644 --- a/tests/test_atoms_state.py +++ b/tests/test_atoms_state.py @@ -16,18 +16,17 @@ # limitations under the License. # -import pytest -import numpy as np -from typing import List, Union, Optional, Tuple +from typing import Optional, Union -from nomad.units import ureg +import numpy as np +import pytest from nomad.datamodel import EntryArchive - +from nomad.units import ureg from nomad_simulations.schema_packages.atoms_state import ( - OrbitalsState, + AtomsState, CoreHole, HubbardInteractions, - AtomsState, + OrbitalsState, ) from . import logger @@ -44,8 +43,8 @@ def add_state( l_number: int, ml_number: Optional[int], ms_number: Optional[float], - j_number: Optional[List[float]], - mj_number: Optional[List[float]], + j_number: Optional[list[float]], + mj_number: Optional[list[float]], ) -> None: """Adds l and ml quantum numbers to the `OrbitalsState` section.""" orbital_state.l_quantum_number = l_number @@ -65,7 +64,7 @@ def add_state( ], ) def test_validate_quantum_numbers( - self, number_label: str, values: List[int], results: List[bool] + self, number_label: str, values: list[int], results: list[bool] ): """ Test the `validate_quantum_numbers` method. @@ -149,8 +148,8 @@ def test_degeneracy( self, l_quantum_number: int, ml_quantum_number: Optional[int], - j_quantum_number: Optional[List[float]], - mj_quantum_number: Optional[List[float]], + j_quantum_number: Optional[list[float]], + mj_quantum_number: Optional[list[float]], ms_quantum_number: Optional[float], degeneracy: int, ): @@ -160,8 +159,8 @@ def test_degeneracy( Args: l_quantum_number (int): The angular momentum quantum number. ml_quantum_number (Optional[int]): The magnetic quantum number. - j_quantum_number (Optional[List[float]]): The total angular momentum quantum number. - mj_quantum_number (Optional[List[float]]): The magnetic quantum number for the total angular momentum. + j_quantum_number (Optional[list[float]]): The total angular momentum quantum number. + mj_quantum_number (Optional[list[float]]): The magnetic quantum number for the total angular momentum. ms_quantum_number (Optional[float]): The spin quantum number. degeneracy (int): The expected degeneracy of the orbital state. """ @@ -252,7 +251,7 @@ def test_normalize( orbital_ref: Optional[OrbitalsState], n_excited_electrons: Optional[float], dscf_state: Optional[str], - results: Tuple[Optional[float], Optional[float], Optional[float]], + results: tuple[Optional[float], Optional[float], Optional[float]], ): """ Test the normalization of the `CoreHole`. Inputs are defined as the quantities of the `CoreHole` section. @@ -261,7 +260,7 @@ def test_normalize( orbital_ref (Optional[OrbitalsState]): The orbital reference of the core hole. n_excited_electrons (Optional[float]): The number of excited electrons. dscf_state (Optional[str]): The DSCF state of the core hole. - results (Tuple[Optional[float], Optional[float], Optional[float]]): The expected results after normalization. + results (tuple[Optional[float], Optional[float], Optional[float]]): The expected results after normalization. """ core_hole = CoreHole( orbital_ref=orbital_ref, @@ -290,15 +289,15 @@ class TestHubbardInteractions: ) def test_u_interactions( self, - slater_integrals: Optional[List[float]], - results: Tuple[Optional[float], Optional[float], Optional[float]], + slater_integrals: Optional[list[float]], + results: tuple[Optional[float], Optional[float], Optional[float]], ): """ Test the Hubbard interactions `U`, `U'`, and `J` for a given set of Slater integrals. Args: - slater_integrals (Optional[List[float]]): The Slater integrals of the Hubbard interactions. - results (Tuple[Optional[float], Optional[float], Optional[float]]): The expected results of the Hubbard interactions. + slater_integrals (Optional[list[float]]): The Slater integrals of the Hubbard interactions. + results (tuple[Optional[float], Optional[float], Optional[float]]): The expected results of the Hubbard interactions. """ # Adding `slater_integrals` to the `HubbardInteractions` section hubbard_interactions = HubbardInteractions() diff --git a/tests/test_band_gap.py b/tests/test_band_gap.py index 19840421..20688217 100644 --- a/tests/test_band_gap.py +++ b/tests/test_band_gap.py @@ -16,13 +16,12 @@ # limitations under the License. # -import pytest -import numpy as np -from typing import Optional, List, Union +from typing import Optional, Union -from nomad.units import ureg +import numpy as np +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 @@ -56,7 +55,7 @@ def test_default_quantities(self): ([1.0, 2.0, -1.0], None), ], ) - def test_validate_values(self, value: Union[List[float], float], result: float): + def test_validate_values(self, value: Union[list[float], float], result: float): """ Test the `validate_values` method. """ @@ -94,7 +93,7 @@ def test_validate_values(self, value: Union[List[float], float], result: float): ], ) def test_resolve_type( - self, momentum_transfer: Optional[List[float]], type: str, result: Optional[str] + self, momentum_transfer: Optional[list[float]], type: str, result: Optional[str] ): """ Test the `resolve_type` method. diff --git a/tests/test_band_structure.py b/tests/test_band_structure.py index d7a546a4..2e410112 100644 --- a/tests/test_band_structure.py +++ b/tests/test_band_structure.py @@ -16,12 +16,11 @@ # limitations under the License. # -import pytest -import numpy as np -from typing import Optional, Tuple, List +from typing import Optional +import numpy as np +import pytest from nomad.datamodel import EntryArchive - from nomad_simulations.schema_packages.properties import ElectronicEigenvalues from . import logger @@ -50,7 +49,7 @@ def test_default_quantities(self, n_bands: Optional[int], rank: Optional[list]): electronic_eigenvalues = ElectronicEigenvalues(n_bands=n_bands) assert ( str(exc_info.value) - == f'`n_bands` is not defined during initialization of the class.' + == '`n_bands` is not defined during initialization of the class.' ) else: electronic_eigenvalues = ElectronicEigenvalues(n_bands=n_bands) @@ -160,7 +159,7 @@ def test_order_eigenvalues( occupation: Optional[list], value: Optional[list], result_validation: bool, - result: Tuple[list, list], + result: tuple[list, list], ): """ Test the `order_eigenvalues` method. @@ -263,7 +262,7 @@ def test_homo_lumo_eigenvalues( value: Optional[list], highest_occupied: Optional[float], lowest_unoccupied: Optional[float], - result: Tuple[Optional[float], Optional[float]], + result: tuple[Optional[float], Optional[float]], ): """ Test the `resolve_homo_lumo_eigenvalues` method. @@ -407,8 +406,8 @@ def test_extract_fermi_surface(self): ) def test_resolve_reciprocal_cell( self, - reciprocal_lattice_vectors: Optional[List[List[float]]], - result: Optional[List[List[float]]], + reciprocal_lattice_vectors: Optional[list[list[float]]], + result: Optional[list[list[float]]], ): """ Test the `resolve_reciprocal_cell` method. This is done via the `normalize` function because `reciprocal_cell` is a diff --git a/tests/test_energies.py b/tests/test_energies.py index 6dc2daeb..589242c4 100644 --- a/tests/test_energies.py +++ b/tests/test_energies.py @@ -18,9 +18,9 @@ from nomad_simulations.schema_packages.properties import ( FermiLevel, - TotalEnergy, KineticEnergy, PotentialEnergy, + TotalEnergy, ) diff --git a/tests/test_fermi_surface.py b/tests/test_fermi_surface.py index 9b57dede..dde4ce1f 100644 --- a/tests/test_fermi_surface.py +++ b/tests/test_fermi_surface.py @@ -16,9 +16,9 @@ # limitations under the License. # -import pytest from typing import Optional +import pytest from nomad_simulations.schema_packages.properties import FermiSurface @@ -44,7 +44,7 @@ def test_default_quantities(self, n_bands: Optional[int], rank: Optional[list]): fermi_surface = FermiSurface(n_bands=n_bands) assert ( str(exc_info.value) - == f'`n_bands` is not defined during initialization of the class.' + == '`n_bands` is not defined during initialization of the class.' ) else: fermi_surface = FermiSurface(n_bands=n_bands) diff --git a/tests/test_general.py b/tests/test_general.py index 64d9d610..e722e03e 100644 --- a/tests/test_general.py +++ b/tests/test_general.py @@ -16,17 +16,14 @@ # limitations under the License. # -import pytest import numpy as np -from typing import List - +import pytest from nomad.datamodel import EntryArchive - from nomad_simulations.schema_packages.general import Simulation from nomad_simulations.schema_packages.model_system import ( - ModelSystem, AtomicCell, AtomsState, + ModelSystem, ) from . import logger @@ -71,14 +68,14 @@ class TestSimulation: ], ) def test_set_system_branch_depth( - self, system: List[ModelSystem], result: List[int] + self, system: list[ModelSystem], result: list[int] ): """ Test the `_set_system_branch_depth` method. Args: - system (List[ModelSystem]): The system hierarchy to set the branch depths for. - result (List[int]): The expected branch depths for each system in the hierarchy. + system (list[ModelSystem]): The system hierarchy to set the branch depths for. + result (list[int]): The expected branch depths for each system in the hierarchy. """ simulation = Simulation(model_system=system) for system_parent in simulation.model_system: @@ -189,11 +186,11 @@ def test_system_hierarchy_for_molecules( self, is_representative: bool, has_atom_indices: bool, - mol_label_list: List[str], - n_mol_list: List[int], - atom_labels_list: List[str], - composition_formula_list: List[str], - custom_formulas: List[str], + mol_label_list: list[str], + n_mol_list: list[int], + atom_labels_list: list[str], + composition_formula_list: list[str], + custom_formulas: list[str], ): """ Test the `Simulation` normalization for obtaining `Model.System.composition_formula` for atoms and molecules. @@ -204,12 +201,12 @@ def test_system_hierarchy_for_molecules( has_atom_indices (bool): Specifies if the atom_indices should be populated during parsing. Without atom_indices, the composition formulas for the deepest level of the hierarchy should not be populated. - mol_label_list (List[str]): Molecule types for generating the hierarchy. - n_mol_list (List[int]): Number of molecules for each molecule type. Should be same + mol_label_list (list[str]): Molecule types for generating the hierarchy. + n_mol_list (list[int]): Number of molecules for each molecule type. Should be same length as mol_label_list. - atom_labels_list (List[str]): Atom labels for each molecule type. Should be same length as + atom_labels_list (list[str]): Atom labels for each molecule type. Should be same length as mol_label_list, with each entry being a list of corresponding atom labels. - composition_formula_list (List[str]): Resulting composition formulas after normalization. The + composition_formula_list (list[str]): Resulting composition formulas after normalization. The ordering is dictated by the recursive traversing of the hierarchy in get_system_recurs(), which follows each branch to its deepest level before moving to the next branch, i.e., [model_system.composition_formula, @@ -217,7 +214,7 @@ def test_system_hierarchy_for_molecules( model_system.model_system[0].model_system[0].composition_formula, model_system.model_system[0].model_system[1].composition_formula, ..., model_system.model_system[1].composition_formula, ...] - custom_formulas (List[str]): Custom composition formulas that can be set in the generation + custom_formulas (list[str]): Custom composition formulas that can be set in the generation of the hierarchy, which will cause the normalize to ignore (i.e., not overwrite) these formula entries. The ordering is as described above. """ @@ -278,7 +275,7 @@ def test_system_hierarchy_for_molecules( ctr_comp = 1 # TODO move this into its own method to handle `ModelSystem` hierarchies (see above `get_flat_depths`) - def get_system_recurs(systems: List[ModelSystem], ctr_comp: int) -> int: + def get_system_recurs(systems: list[ModelSystem], ctr_comp: int) -> int: for sys in systems: assert sys.composition_formula == composition_formula_list[ctr_comp] ctr_comp += 1 @@ -287,6 +284,4 @@ def get_system_recurs(systems: List[ModelSystem], ctr_comp: int) -> int: ctr_comp = get_system_recurs(subsystems, ctr_comp) return ctr_comp - new_ctr_comp = get_system_recurs( - systems=model_system.model_system, ctr_comp=ctr_comp - ) + _ = get_system_recurs(systems=model_system.model_system, ctr_comp=ctr_comp) diff --git a/tests/test_hopping_matrix.py b/tests/test_hopping_matrix.py index 7cbef83b..cfe6ada2 100644 --- a/tests/test_hopping_matrix.py +++ b/tests/test_hopping_matrix.py @@ -16,12 +16,12 @@ # limitations under the License. # -import pytest from typing import Optional +import pytest from nomad_simulations.schema_packages.properties import ( - HoppingMatrix, CrystalFieldSplitting, + HoppingMatrix, ) @@ -47,7 +47,7 @@ def test_default_quantities(self, n_orbitals: Optional[int], rank: Optional[list hopping_matrix = HoppingMatrix(n_orbitals=n_orbitals) assert ( str(exc_info.value) - == f'`n_orbitals` is not defined during initialization of the class.' + == '`n_orbitals` is not defined during initialization of the class.' ) else: hopping_matrix = HoppingMatrix(n_orbitals=n_orbitals) @@ -78,7 +78,7 @@ def test_default_quantities(self, n_orbitals: Optional[int], rank: Optional[list crystal_field = CrystalFieldSplitting(n_orbitals=n_orbitals) assert ( str(exc_info.value) - == f'`n_orbitals` is not defined during initialization of the class.' + == '`n_orbitals` is not defined during initialization of the class.' ) else: crystal_field = CrystalFieldSplitting(n_orbitals=n_orbitals) diff --git a/tests/test_model_method.py b/tests/test_model_method.py index c7c4d18b..b66c5e25 100644 --- a/tests/test_model_method.py +++ b/tests/test_model_method.py @@ -16,20 +16,19 @@ # limitations under the License. # -import pytest -from typing import List, Optional +from typing import Optional +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 ( TB, - Wannier, SlaterKoster, SlaterKosterBond, + Wannier, ) -from nomad_simulations.schema_packages.atoms_state import OrbitalsState, AtomsState -from nomad_simulations.schema_packages.model_system import ModelSystem, AtomicCell +from nomad_simulations.schema_packages.model_system import AtomicCell, ModelSystem from . import logger from .conftest import generate_simulation @@ -146,17 +145,17 @@ def test_resolve_type(self, tb_section: TB, result: Optional[str]): ) def test_resolve_orbital_references( self, - model_systems: Optional[List[ModelSystem]], + model_systems: Optional[list[ModelSystem]], model_index: int, - result: Optional[List[OrbitalsState]], + result: Optional[list[OrbitalsState]], ): """ Test the `resolve_orbital_references` method. Args: - model_systems (Optional[List[ModelSystem]]): The `model_system` section to add to `Simulation`. + model_systems (Optional[list[ModelSystem]]): The `model_system` section to add to `Simulation`. model_index (int): The index of the `ModelSystem` section to resolve the orbital references from. - result (Optional[List[OrbitalsState]]): The expected orbital references. + result (Optional[list[OrbitalsState]]): The expected orbital references. """ tb_method = TB() simulation = generate_simulation(model_method=tb_method) @@ -302,8 +301,8 @@ def test_normalize( self, tb_section: TB, result_type: Optional[str], - model_systems: Optional[List[ModelSystem]], - result: Optional[List[OrbitalsState]], + model_systems: Optional[list[ModelSystem]], + result: Optional[list[OrbitalsState]], ): """ Test the `resolve_orbital_references` method. @@ -311,8 +310,8 @@ def test_normalize( Args: tb_section (TB): The TB section to resolve the type from. result_type (Optional[str]): The expected type of the TB section. - model_systems (Optional[List[ModelSystem]]): The `model_system` section to add to `Simulation`. - result (Optional[List[OrbitalsState]]): The expected orbital references. + model_systems (Optional[list[ModelSystem]]): The `model_system` section to add to `Simulation`. + result (Optional[list[OrbitalsState]]): The expected orbital references. """ simulation = generate_simulation(model_method=tb_section) simulation.model_system = model_systems @@ -467,7 +466,7 @@ def test_normalize( """ sk_bond = SlaterKosterBond() atoms_state = AtomsState() - simulation = Simulation( + _ = Simulation( model_system=[ModelSystem(cell=[AtomicCell(atoms_state=[atoms_state])])] ) if orbital_1 is not None: diff --git a/tests/test_model_system.py b/tests/test_model_system.py index 5dd8a04e..ecb67a76 100644 --- a/tests/test_model_system.py +++ b/tests/test_model_system.py @@ -16,16 +16,15 @@ # limitations under the License. # -import pytest -import numpy as np -from typing import List, Optional +from typing import Optional +import numpy as np +import pytest from nomad.datamodel import EntryArchive - from nomad_simulations.schema_packages.model_system import ( - Symmetry, ChemicalFormula, ModelSystem, + Symmetry, ) from . import logger @@ -84,23 +83,23 @@ class TestAtomicCell: ) def test_generate_ase_atoms( self, - chemical_symbols: List[str], - atomic_numbers: List[int], + chemical_symbols: list[str], + atomic_numbers: list[int], formula: str, - lattice_vectors: List[List[float]], - positions: List[List[float]], - periodic_boundary_conditions: List[bool], + lattice_vectors: list[list[float]], + positions: list[list[float]], + periodic_boundary_conditions: list[bool], ): """ Test the creation of `ase.Atoms` from `AtomicCell`. Args: - chemical_symbols (List[str]): List of chemical symbols. - atomic_numbers (List[int]): List of atomic numbers. + chemical_symbols (list[str]): List of chemical symbols. + atomic_numbers (list[int]): List of atomic numbers. formula (str): Chemical formula. - lattice_vectors (List[List[float]]): Lattice vectors. - positions (List[List[float]]): Atomic positions. - periodic_boundary_conditions (List[bool]): Periodic boundary conditions. + lattice_vectors (list[list[float]]): Lattice vectors. + positions (list[list[float]]): Atomic positions. + periodic_boundary_conditions (list[bool]): Periodic boundary conditions. """ atomic_cell = generate_atomic_cell( lattice_vectors=lattice_vectors, @@ -185,24 +184,24 @@ def test_generate_ase_atoms( ) def test_geometric_space( self, - chemical_symbols: List[str], - atomic_numbers: List[int], - lattice_vectors: List[List[float]], - positions: List[List[float]], - vectors_results: List[Optional[float]], - angles_results: List[Optional[float]], + chemical_symbols: list[str], + atomic_numbers: list[int], + lattice_vectors: list[list[float]], + positions: list[list[float]], + vectors_results: list[Optional[float]], + angles_results: list[Optional[float]], volume: Optional[float], ): """ Test the `GeometricSpace` quantities normalization from `AtomicCell`. Args: - chemical_symbols (List[str]): List of chemical symbols. - atomic_numbers (List[int]): List of atomic numbers. - lattice_vectors (List[List[float]]): Lattice vectors. - positions (List[List[float]]): Atomic positions. - vectors_results (List[Optional[float]]): Expected lengths of cell vectors. - angles_results (List[Optional[float]]): Expected angles between cell vectors. + chemical_symbols (list[str]): List of chemical symbols. + atomic_numbers (list[int]): List of atomic numbers. + lattice_vectors (list[list[float]]): Lattice vectors. + positions (list[list[float]]): Atomic positions. + vectors_results (list[Optional[float]]): Expected lengths of cell vectors. + angles_results (list[Optional[float]]): Expected angles between cell vectors. volume (Optional[float]): Expected volume of the cell. """ atomic_cell = generate_atomic_cell( @@ -281,17 +280,17 @@ def test_empty_chemical_formula(self): ) def test_chemical_formula( self, - chemical_symbols: List[str], - atomic_numbers: List[int], - formulas: List[str], + chemical_symbols: list[str], + atomic_numbers: list[int], + formulas: list[str], ): """ Test the `ChemicalFormula` normalization if a sibling `AtomicCell` is created, and thus the `Formula` class can be used. Args: - chemical_symbols (List[str]): List of chemical symbols. - atomic_numbers (List[int]): List of atomic numbers. - formulas (List[str]): List of expected formulas. + chemical_symbols (list[str]): List of chemical symbols. + atomic_numbers (list[int]): List of atomic numbers. + formulas (list[str]): List of expected formulas. """ atomic_cell = generate_atomic_cell( chemical_symbols=chemical_symbols, atomic_numbers=atomic_numbers @@ -342,8 +341,8 @@ def test_chemical_formula( ) def test_system_type_and_dimensionality( self, - positions: List[List[float]], - pbc: Optional[List[bool]], + positions: list[list[float]], + pbc: Optional[list[bool]], system_type: str, dimensionality: int, ): @@ -351,8 +350,8 @@ def test_system_type_and_dimensionality( Test the `ModelSystem` normalization of `type` and `dimensionality` from `AtomicCell`. Args: - positions (List[List[float]]): Atomic positions. - pbc (Optional[List[bool]]): Periodic boundary conditions. + positions (list[list[float]]): Atomic positions. + pbc (Optional[list[bool]]): Periodic boundary conditions. system_type (str): Expected system type. dimensionality (int): Expected dimensionality. """ diff --git a/tests/test_numerical_settings.py b/tests/test_numerical_settings.py index ef5a362c..966d2651 100644 --- a/tests/test_numerical_settings.py +++ b/tests/test_numerical_settings.py @@ -16,16 +16,15 @@ # limitations under the License. # -import pytest -import numpy as np -from typing import Optional, List +from typing import Optional -from nomad.units import ureg +import numpy as np +import pytest from nomad.datamodel import EntryArchive - +from nomad.units import ureg from nomad_simulations.schema_packages.numerical_settings import ( - KMesh, KLinePath, + KMesh, KSpaceFunctionalities, ) @@ -56,8 +55,8 @@ def test_normalize( self, system_type: Optional[str], is_representative: bool, - reciprocal_lattice_vectors: Optional[List[List[float]]], - result: List[List[float]], + reciprocal_lattice_vectors: Optional[list[list[float]]], + result: list[list[float]], ): """ Test the `normalize` method. This also test the `resolve_reciprocal_lattice_vectors` method. @@ -96,9 +95,9 @@ class TestKSpaceFunctionalities: ) def test_validate_reciprocal_lattice_vectors( self, - reciprocal_lattice_vectors: Optional[List[List[float]]], + reciprocal_lattice_vectors: Optional[list[list[float]]], check_grid: bool, - grid: Optional[List[int]], + grid: Optional[list[int]], result: bool, ): """ @@ -238,8 +237,8 @@ def test_resolve_k_line_density( self, system_type: Optional[str], is_representative: bool, - grid: Optional[List[int]], - reciprocal_lattice_vectors: Optional[List[List[float]]], + grid: Optional[list[int]], + reciprocal_lattice_vectors: Optional[list[list[float]]], result_get_k_line_density: Optional[float], result_k_line_density: Optional[float], ): @@ -298,8 +297,8 @@ class TestKLinePath: ) def test_validate_high_symmetry_path( self, - high_symmetry_path_names: List[str], - high_symmetry_path_values: List[List[float]], + high_symmetry_path_names: list[str], + high_symmetry_path_values: list[list[float]], result: bool, ): """ @@ -325,9 +324,9 @@ def test_validate_high_symmetry_path( ) def test_resolve_high_symmetry_path_values( self, - reciprocal_lattice_vectors: Optional[List[List[float]]], - high_symmetry_path_names: List[str], - result: List[float], + reciprocal_lattice_vectors: Optional[list[list[float]]], + high_symmetry_path_names: list[str], + result: list[float], ): """ Test the `resolve_high_symmetry_path_values` method. Only testing the valid situation in which the `ModelSystem` normalization worked. diff --git a/tests/test_outputs.py b/tests/test_outputs.py index 7b06486d..73eef906 100644 --- a/tests/test_outputs.py +++ b/tests/test_outputs.py @@ -16,19 +16,18 @@ # limitations under the License. # -import pytest -from typing import Optional, List +from typing import Optional +import pytest from nomad.datamodel import EntryArchive - -from nomad_simulations.schema_packages.model_system import ModelSystem 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 from nomad_simulations.schema_packages.outputs import Outputs, SCFOutputs from nomad_simulations.schema_packages.properties import ElectronicBandGap from . import logger -from .conftest import generate_simulation, generate_scf_electronic_band_gap_template +from .conftest import generate_scf_electronic_band_gap_template, generate_simulation class TestOutputs: @@ -83,19 +82,19 @@ def test_number_of_properties(self): ) def test_extract_spin_polarized_properties( self, - band_gaps: List[ElectronicBandGap], - values: List[float], + band_gaps: list[ElectronicBandGap], + values: list[float], result_length: int, - result: List[ElectronicBandGap], + result: list[ElectronicBandGap], ): """ Test the `extract_spin_polarized_property` method. Args: - band_gaps (List[ElectronicBandGap]): The `ElectronicBandGap` sections to be stored under `Outputs`. - values (List[float]): The values to be assigned to the `ElectronicBandGap` sections. + band_gaps (list[ElectronicBandGap]): The `ElectronicBandGap` sections to be stored under `Outputs`. + values (list[float]): The values to be assigned to the `ElectronicBandGap` sections. result_length (int): The expected length extracted from `extract_spin_polarized_property`. - result (List[ElectronicBandGap]): The expected result of the `extract_spin_polarized_property` method. + result (list[ElectronicBandGap]): The expected result of the `extract_spin_polarized_property` method. """ outputs = Outputs() @@ -256,11 +255,11 @@ class TestSCFOutputs: ) def test_get_last_scf_steps_value( self, - scf_last_steps: List[Outputs], + scf_last_steps: list[Outputs], i_property: int, - values: List[float], + values: list[float], scf_parameters: Optional[SelfConsistency], - result: List[float], + result: list[float], ): scf_outputs = SCFOutputs() for i, scf_step in enumerate(scf_last_steps): diff --git a/tests/test_permittivity.py b/tests/test_permittivity.py index 43b563e4..9cb58fbc 100644 --- a/tests/test_permittivity.py +++ b/tests/test_permittivity.py @@ -16,12 +16,12 @@ # limitations under the License. # -import pytest -import numpy as np -from typing import List, Optional +from typing import Optional +import numpy as np +import pytest from nomad_simulations.schema_packages.properties import Permittivity -from nomad_simulations.schema_packages.variables import Variables, KMesh, Frequency +from nomad_simulations.schema_packages.variables import Frequency, KMesh, Variables from . import logger from .conftest import generate_k_space_simulation @@ -53,7 +53,7 @@ def test_default_quantities(self): ) def test_resolve_type( self, - kmesh_grid: Optional[List[int]], + kmesh_grid: Optional[list[int]], variables: Optional[Variables], result: str, ): @@ -118,10 +118,10 @@ def test_resolve_type( ) def test_extract_absorption_spectra( self, - kmesh_grid: Optional[List[int]], - frequencies_points: Optional[List[float]], + kmesh_grid: Optional[list[int]], + frequencies_points: Optional[list[float]], value: Optional[np.ndarray], - result: Optional[List[float]], + result: Optional[list[float]], ): """ Test the `extract_absorption_spectra` method. The `result` in the last valid case corresponds to the imaginary part of diff --git a/tests/test_physical_properties.py b/tests/test_physical_properties.py index e3ebd83b..12191221 100644 --- a/tests/test_physical_properties.py +++ b/tests/test_physical_properties.py @@ -16,19 +16,18 @@ # limitations under the License. # +from typing import Optional, Union + import numpy as np import pytest -from typing import Union, Optional - -from nomad.units import ureg from nomad.datamodel import EntryArchive from nomad.metainfo import Quantity - -from nomad_simulations.schema_packages.variables import Variables +from nomad.units import ureg from nomad_simulations.schema_packages.physical_property import ( PhysicalProperty, validate_quantity_wrt_value, ) +from nomad_simulations.schema_packages.variables import Variables from . import logger diff --git a/tests/test_spectral_profile.py b/tests/test_spectral_profile.py index 6e898118..003bd029 100644 --- a/tests/test_spectral_profile.py +++ b/tests/test_spectral_profile.py @@ -16,21 +16,20 @@ # limitations under the License. # -import pytest -import numpy as np -from typing import List, Optional +from typing import Optional -from nomad.units import ureg +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 ModelSystem, AtomicCell +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 from nomad_simulations.schema_packages.outputs import Outputs from nomad_simulations.schema_packages.properties import ( - SpectralProfile, - ElectronicDensityOfStates, AbsorptionSpectrum, + ElectronicDensityOfStates, + SpectralProfile, XASSpectrum, ) from nomad_simulations.schema_packages.variables import Energy2 as Energy @@ -196,8 +195,8 @@ def test_extract_projected_dos(self, simulation_electronic_dos: Simulation): def test_generate_from_pdos( self, simulation_electronic_dos: Simulation, - value: Optional[List[float]], - result: List[float], + value: Optional[list[float]], + result: list[float], ): """ Test the `generate_from_projected_dos` method. @@ -281,9 +280,9 @@ def test_default_quantities(self): ) def test_generate_from_contributions( self, - xanes_energies: Optional[List[float]], - exafs_energies: Optional[List[float]], - xas_values: Optional[List[float]], + xanes_energies: Optional[list[float]], + exafs_energies: Optional[list[float]], + xas_values: Optional[list[float]], ): """ Test the `generate_from_contributions` method. diff --git a/tests/test_thermodynamics.py b/tests/test_thermodynamics.py index 887b44b0..1fe9c842 100644 --- a/tests/test_thermodynamics.py +++ b/tests/test_thermodynamics.py @@ -17,21 +17,21 @@ # from nomad_simulations.schema_packages.properties import ( - Pressure, - Volume, - Temperature, - Heat, - Work, - InternalEnergy, + ChemicalPotential, Enthalpy, Entropy, GibbsFreeEnergy, - HelmholtzFreeEnergy, - ChemicalPotential, + Heat, HeatCapacity, - VirialTensor, - MassDensity, + HelmholtzFreeEnergy, Hessian, + InternalEnergy, + MassDensity, + Pressure, + Temperature, + VirialTensor, + Volume, + Work, ) diff --git a/tests/test_utils.py b/tests/test_utils.py index 80fddf5c..8cf7512a 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -17,18 +17,18 @@ # import pytest - -from nomad_simulations.schema_packages.utils import ( - get_sibling_section, - is_not_representative, - get_variables, -) from nomad_simulations.schema_packages.model_system import ( - ModelSystem, AtomicCell, + ModelSystem, Symmetry, ) -from nomad_simulations.schema_packages.variables import Temperature, Energy2 as Energy +from nomad_simulations.schema_packages.utils import ( + get_sibling_section, + get_variables, + is_not_representative, +) +from nomad_simulations.schema_packages.variables import Energy2 as Energy +from nomad_simulations.schema_packages.variables import Temperature from . import logger diff --git a/tests/test_variables.py b/tests/test_variables.py index 9f40be65..2fd63a00 100644 --- a/tests/test_variables.py +++ b/tests/test_variables.py @@ -17,9 +17,7 @@ # import pytest - from nomad.datamodel import EntryArchive - from nomad_simulations.schema_packages.variables import Variables from . import logger