Skip to content

Commit

Permalink
Fix ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
JosePizarro3 committed Aug 27, 2024
1 parent 40deb93 commit 2233f34
Show file tree
Hide file tree
Showing 19 changed files with 64 additions and 31 deletions.
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,18 @@ indent-width = 4
[tool.ruff.lint]
select = [
"E", # pycodestyle
"W", # pycodestyle
"PL", # pylint
"F", # Pyflakes
"UP", # pyupgrade
"I", # isort
]

ignore = [
"F401", # Module imported but unused
"E501", # Line too long ({width} > {limit} characters)
"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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class BaseGreensFunction(PhysicalProperty):
Further information in M. Wallerberger et al., Comput. Phys. Commun. 235, 2 (2019).
"""

# ! we use `atoms_state_ref` and `orbitals_state_ref` to enforce order in the matrices

n_atoms = Quantity(
Expand Down Expand Up @@ -108,7 +109,22 @@ class BaseGreensFunction(PhysicalProperty):
)

space_id = Quantity(
type=MEnum('r', 'rt', 'rw', 'rit', 'riw', 'k', 'kt', 'kw', 'kit', 'kiw', 't', 'it', 'w', 'iw'),
type=MEnum(
'r',
'rt',
'rw',
'rit',
'riw',
'k',
'kt',
'kw',
'kit',
'kiw',
't',
'it',
'w',
'iw',
),
description="""
String used to identify the space in which the Green's function property is represented. The spaces are:
Expand Down Expand Up @@ -136,7 +152,10 @@ def __init__(
) -> None:
super().__init__(m_def, m_context, **kwargs)
# ! n_orbitals need to be set up during initialization of the class
self.rank = [int(kwargs.get('n_atoms')), int(kwargs.get('n_correlated_orbitals'))]
self.rank = [
int(kwargs.get('n_atoms')),
int(kwargs.get('n_correlated_orbitals')),
]

def resolve_space_id(self) -> str:
"""
Expand Down Expand Up @@ -167,7 +186,9 @@ def find_space_id(space_map: dict) -> str:
str: _description_
"""
for space_id, variable_cls in space_map.items():
space_variable = get_variables(variables=self.variables, variable_cls=variable_cls)
space_variable = get_variables(
variables=self.variables, variable_cls=variable_cls
)
if len(space_variable) > 0:
return space_id
return ''
Expand All @@ -179,12 +200,13 @@ def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
super().normalize(archive, logger)

space_id = self.resolve_space_id()
if (self.space_id is not None and self.space_id != space_id):
if self.space_id is not None and self.space_id != space_id:
logger.warning(
f'The stored `space_id`, {self.space_id}, does not coincide with the resolved one, {space_id}. We will update it.'
)
self.space_id = space_id


class ElectronicGreensFunction(BaseGreensFunction):
"""
Charge-charge correlation functions.
Expand Down Expand Up @@ -271,12 +293,18 @@ class QuasiparticleWeight(PhysicalProperty):
electron-electron interactions and takes values between 0 and 1, with Z = 1 representing a non-correlated
system, and Z = 0 the Mott state.
"""

# ! we use `atoms_state_ref` and `orbitals_state_ref` to enforce order in the matrices

iri = 'http://fairmat-nfdi.eu/taxonomy/HybridizationFunction'

system_correlation_strengths = Quantity(
type=MEnum('non-correlated metal', 'strongly-correlated metal', 'OSMI', 'Mott insulator'),
type=MEnum(
'non-correlated metal',
'strongly-correlated metal',
'OSMI',
'Mott insulator',
),
description="""
String used to identify the type of system based on the strength of the electron-electron interactions.
Expand Down Expand Up @@ -338,7 +366,10 @@ def __init__(
) -> None:
super().__init__(m_def, m_context, **kwargs)
# ! n_orbitals need to be set up during initialization of the class
self.rank = [int(kwargs.get('n_atoms')), int(kwargs.get('n_correlated_orbitals'))]
self.rank = [
int(kwargs.get('n_atoms')),
int(kwargs.get('n_correlated_orbitals')),
]
self.name = self.m_def.name

def is_valid_quasiparticle_weight(self) -> bool:
Expand Down Expand Up @@ -380,7 +411,10 @@ def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
return

system_correlation_strengths = self.resolve_system_correlation_strengths()
if (self.system_correlation_strengths is not None and self.system_correlation_strengths != system_correlation_strengths):
if (
self.system_correlation_strengths is not None
and self.system_correlation_strengths != system_correlation_strengths
):
logger.warning(
f'The stored `system_correlation_strengths`, {self.system_correlation_strengths}, does not coincide with the resolved one, {system_correlation_strengths}. We will update it.'
)
Expand Down
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
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
Expand Down
1 change: 0 additions & 1 deletion tests/test_atoms_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import pytest
from nomad.datamodel import EntryArchive
from nomad.units import ureg

from nomad_simulations.schema_packages.atoms_state import (
AtomsState,
CoreHole,
Expand Down
1 change: 0 additions & 1 deletion tests/test_band_gap.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
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

Expand Down
1 change: 0 additions & 1 deletion tests/test_band_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import numpy as np
import pytest
from nomad.datamodel import EntryArchive

from nomad_simulations.schema_packages.properties import ElectronicEigenvalues

from . import logger
Expand Down
1 change: 0 additions & 1 deletion tests/test_fermi_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from typing import Optional

import pytest

from nomad_simulations.schema_packages.properties import FermiSurface


Expand Down
1 change: 0 additions & 1 deletion tests/test_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
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,
Expand Down
28 changes: 22 additions & 6 deletions tests/test_greens_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import pytest
from nomad.datamodel import EntryArchive

from nomad_simulations.schema_packages.properties import (
QuasiparticleWeight,
)
Expand Down Expand Up @@ -64,7 +63,15 @@ class TestBaseGreensFunction:
([KMesh(), MatsubaraFrequency()], 'kiw'),
],
)
def test_resolve_space_id(self, variables: list[Union[WignerSeitz, KMesh, Time, ImaginaryTime, Frequency, MatsubaraFrequency]], result: str):
def test_resolve_space_id(
self,
variables: list[
Union[
WignerSeitz, KMesh, Time, ImaginaryTime, Frequency, MatsubaraFrequency
]
],
result: str,
):
"""
Test the `resolve_space_id` method of the `BaseGreensFunction` class.
"""
Expand Down Expand Up @@ -94,7 +101,16 @@ def test_resolve_space_id(self, variables: list[Union[WignerSeitz, KMesh, Time,
('', [KMesh(), MatsubaraFrequency()], 'kiw'),
],
)
def test_normalize(self, space_id: str, variables: list[Union[WignerSeitz, KMesh, Time, ImaginaryTime, Frequency, MatsubaraFrequency]], result: Optional[str]):
def test_normalize(
self,
space_id: str,
variables: list[
Union[
WignerSeitz, KMesh, Time, ImaginaryTime, Frequency, MatsubaraFrequency
]
],
result: Optional[str],
):
"""
Test the `normalize` method of the `BaseGreensFunction` class.
"""
Expand All @@ -105,7 +121,6 @@ def test_normalize(self, space_id: str, variables: list[Union[WignerSeitz, KMesh
assert gfs.space_id == result



class TestQuasiparticleWeight:
"""
Test the `QuasiparticleWeight` class defined in `properties/greens_function.py`.
Expand All @@ -127,7 +142,6 @@ def test_is_valid_quasiparticle_weight(self, value: list[float], result: bool):
quasiparticle_weight.value = value
assert quasiparticle_weight.is_valid_quasiparticle_weight() == result


@pytest.mark.parametrize(
'value, result',
[
Expand All @@ -138,7 +152,9 @@ def test_is_valid_quasiparticle_weight(self, value: list[float], result: bool):
([[1.0, 0.8, 0.2]], None),
],
)
def test_resolve_system_correlation_strengths(self, value: list[float], result: Optional[str]):
def test_resolve_system_correlation_strengths(
self, value: list[float], result: Optional[str]
):
"""
Test the `resolve_system_correlation_strengths` method of the `QuasiparticleWeight` class.
"""
Expand Down
1 change: 0 additions & 1 deletion tests/test_hopping_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from typing import Optional

import pytest

from nomad_simulations.schema_packages.properties import (
CrystalFieldSplitting,
HoppingMatrix,
Expand Down
1 change: 0 additions & 1 deletion tests/test_model_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

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 (
Expand Down
1 change: 0 additions & 1 deletion tests/test_model_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import numpy as np
import pytest
from nomad.datamodel import EntryArchive

from nomad_simulations.schema_packages.model_system import (
ChemicalFormula,
ModelSystem,
Expand Down
1 change: 0 additions & 1 deletion tests/test_numerical_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import pytest
from nomad.datamodel import EntryArchive
from nomad.units import ureg

from nomad_simulations.schema_packages.numerical_settings import (
KLinePath,
KMesh,
Expand Down
1 change: 0 additions & 1 deletion tests/test_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

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
Expand Down
1 change: 0 additions & 1 deletion tests/test_permittivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import numpy as np
import pytest

from nomad_simulations.schema_packages.properties import Permittivity
from nomad_simulations.schema_packages.variables import Frequency, KMesh, Variables

Expand Down
1 change: 0 additions & 1 deletion tests/test_physical_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
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,
Expand Down
1 change: 0 additions & 1 deletion tests/test_spectral_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
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
Expand Down
1 change: 0 additions & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#

import pytest

from nomad_simulations.schema_packages.model_system import (
AtomicCell,
ModelSystem,
Expand Down
1 change: 0 additions & 1 deletion tests/test_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import pytest
from nomad.datamodel import EntryArchive

from nomad_simulations.schema_packages.variables import Variables

from . import logger
Expand Down

1 comment on commit 2233f34

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
src/nomad_simulations
   __init__.py4250%3–4
   _version.py11282%5–6
src/nomad_simulations/schema_packages
   __init__.py14286%53–55
   atoms_state.py1902189%31–33, 219–222, 246, 301–302, 370–371, 373, 555, 567–568, 629–633, 648–652, 659
   general.py75791%29–30, 98, 162, 272–273, 283
   model_method.py2657771%28–30, 189–192, 195–202, 294–295, 315, 336–355, 371–397, 400–417, 771, 782, 824–831, 869, 888, 968, 1025, 1100, 1214
   model_system.py2612292%43–45, 512–515, 562–569, 743–744, 965–969, 975–976, 984–985, 990, 1013
   numerical_settings.py2636575%30–32, 164, 234, 236–237, 240–243, 247–248, 255–258, 267–270, 274–277, 279–282, 287–290, 296–299, 470–497, 572, 607–610, 634, 637, 682, 684–687, 691, 695, 742, 746–767, 822–823, 890, 899–901, 904
   outputs.py1201092%27–28, 270–273, 313–316, 341, 343, 380, 399
   physical_property.py102793%38–40, 220, 349–351
   variables.py861286%26–28, 116, 139, 163, 185, 207, 229, 251, 274, 294
src/nomad_simulations/schema_packages/properties
   band_gap.py51590%26–28, 153–154
   band_structure.py1232580%27–29, 250–283, 296, 303, 339–340, 343, 390–391, 396
   energies.py42979%25–27, 54, 75, 100, 121, 137, 152
   fermi_surface.py17476%25–27, 58
   forces.py22673%26–28, 55, 75, 98
   greens_function.py991387%25–27, 228–229, 232, 253–254, 257, 278–279, 282, 418
   hopping_matrix.py29583%25–27, 76, 112
   permittivity.py48883%25–27, 115–123
   spectral_profile.py26012851%27–29, 75–78, 113–116, 217–318, 374–386, 411–414, 434, 439–442, 484–520, 544, 591–594, 610–611, 616–622
   thermodynamics.py752764%25–27, 53, 74, 90, 99, 108, 119, 128, 155, 165, 175, 190–192, 195, 211, 231–233, 236, 252, 272–274, 277
src/nomad_simulations/schema_packages/utils
   utils.py681479%26–29, 79–88, 97–98, 103, 106
TOTAL223647179% 

Tests Skipped Failures Errors Time
344 0 💤 1 ❌ 0 🔥 2.911s ⏱️

Please sign in to comment.