Skip to content

Commit

Permalink
Fix testing when changing to plural the properties
Browse files Browse the repository at this point in the history
  • Loading branch information
JosePizarro3 committed May 22, 2024
1 parent 3d3b639 commit f2b9bd2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,16 @@ def generate_scf_electronic_band_gap_template(
for i in range(1, n_scf_steps):
value = 1 + sum([1 / (10**j) for j in range(1, i + 1)])
scf_step = Outputs(
electronic_band_gap=[ElectronicBandGap(value=value * ureg.joule)]
electronic_band_gaps=[ElectronicBandGap(value=value * ureg.joule)]
)
scf_outputs.scf_steps.append(scf_step)
# Add a SCF calculated PhysicalProperty
scf_outputs.electronic_band_gap.append(ElectronicBandGap(value=value * ureg.joule))
scf_outputs.electronic_band_gaps.append(ElectronicBandGap(value=value * ureg.joule))
# and a `SelfConsistency` ref section
scf_params = SelfConsistency(
threshold_change=threshold_change, threshold_change_unit='joule'
)
scf_outputs.electronic_band_gap[0].self_consistency_ref = scf_params
scf_outputs.electronic_band_gaps[0].self_consistency_ref = scf_params
return scf_outputs


Expand Down
16 changes: 8 additions & 8 deletions tests/test_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ def test_is_scf_converged(self, threshold_change: float, result: bool):
threshold_change=threshold_change
)
is_scf_converged = scf_outputs.resolve_is_scf_converged(
property_name='electronic_band_gap',
property_name='electronic_band_gaps',
i_property=0,
phys_property=scf_outputs.electronic_band_gap[0],
phys_property=scf_outputs.electronic_band_gaps[0],
logger=logger,
)
assert is_scf_converged == result
Expand All @@ -60,18 +60,18 @@ def test_extract_spin_polarized_properties(self):
# No spin-polarized band gap
band_gap_non_spin_polarized = ElectronicBandGap(variables=[])
band_gap_non_spin_polarized.value = 2.0 * ureg.joule
outputs.electronic_band_gap.append(band_gap_non_spin_polarized)
band_gaps = outputs.extract_spin_polarized_property('electronic_band_gap')
outputs.electronic_band_gaps.append(band_gap_non_spin_polarized)
band_gaps = outputs.extract_spin_polarized_property('electronic_band_gaps')
assert band_gaps == []

# Spin-polarized band gaps
band_gap_spin_1 = ElectronicBandGap(variables=[], spin_channel=0)
band_gap_spin_1.value = 1.0 * ureg.joule
outputs.electronic_band_gap.append(band_gap_spin_1)
outputs.electronic_band_gaps.append(band_gap_spin_1)
band_gap_spin_2 = ElectronicBandGap(variables=[], spin_channel=1)
band_gap_spin_2.value = 1.5 * ureg.joule
outputs.electronic_band_gap.append(band_gap_spin_2)
band_gaps = outputs.extract_spin_polarized_property('electronic_band_gap')
outputs.electronic_band_gaps.append(band_gap_spin_2)
band_gaps = outputs.extract_spin_polarized_property('electronic_band_gaps')
assert len(band_gaps) == 2
assert band_gaps[0].value.magnitude == 1.0
assert band_gaps[1].value.magnitude == 1.5
Expand All @@ -89,4 +89,4 @@ def test_normalize(self, threshold_change: float, result: bool):
)

scf_outputs.normalize(EntryArchive(), logger)
assert scf_outputs.electronic_band_gap[0].is_scf_converged == result
assert scf_outputs.electronic_band_gaps[0].is_scf_converged == result

0 comments on commit f2b9bd2

Please sign in to comment.