Skip to content

Commit

Permalink
Fixed errors
Browse files Browse the repository at this point in the history
Using plural for properties under Outputs
  • Loading branch information
JosePizarro3 committed Aug 15, 2024
1 parent 5de07c9 commit 2efe6e1
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 333 deletions.
10 changes: 5 additions & 5 deletions src/nomad_simulations/schema_packages/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Expand Down
12 changes: 12 additions & 0 deletions src/nomad_simulations/schema_packages/properties/energies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
4 changes: 2 additions & 2 deletions src/nomad_simulations/schema_packages/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ 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)
)


Expand Down
3 changes: 0 additions & 3 deletions tests/test_band_gap.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,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),
Expand Down
34 changes: 0 additions & 34 deletions tests/test_band_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,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]],
Expand Down Expand Up @@ -188,13 +182,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]],
Expand All @@ -217,13 +204,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]],
Expand Down Expand Up @@ -290,13 +270,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]],
Expand All @@ -319,13 +292,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]],
Expand Down
6 changes: 3 additions & 3 deletions tests/test_energies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 == []

Expand All @@ -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 == []

Expand All @@ -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 == []
2 changes: 1 addition & 1 deletion tests/test_forces.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 == []
1 change: 0 additions & 1 deletion tests/test_numerical_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,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),
Expand Down
7 changes: 6 additions & 1 deletion tests/test_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,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',
Expand All @@ -55,6 +55,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

Expand Down
Loading

1 comment on commit 2efe6e1

@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.py1151091%27–28, 247–250, 290–293, 318, 320, 357, 376
   physical_property.py102793%38–40, 220, 349–351
   variables.py651183%26–28, 116, 139, 159–160, 163, 185, 208, 228
src/nomad_simulations/schema_packages/properties
   band_gap.py51590%26–28, 153–154
   band_structure.py1112280%27–29, 249–282, 295, 302, 338–339, 342
   energies.py42979%25–27, 54, 75, 100, 121, 137, 152
   fermi_surface.py17476%25–27, 58
   forces.py22673%26–28, 55, 75, 98
   hopping_matrix.py29583%25–27, 75, 110
   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
TOTAL209845478% 

Tests Skipped Failures Errors Time
297 0 💤 0 ❌ 0 🔥 2.243s ⏱️

Please sign in to comment.