style: apply black formatting to test files

This commit is contained in:
2026-10-02 14:32:04 +03:00
parent 7e31ac4b4e
commit 7f47a876ae
3 changed files with 42 additions and 42 deletions
+9 -9
View File
@@ -637,9 +637,9 @@ class TestMultiBranchEdgeCases:
W, _ = spectrum.get_energy_grid(config) W, _ = spectrum.get_energy_grid(config)
values = spectrum(W) values = spectrum(W)
assert np.all( assert np.all(np.isfinite(values)), (
np.isfinite(values) "High-Z multi-branch must not produce NaN/inf"
), "High-Z multi-branch must not produce NaN/inf" )
def test_no_branches_defaults_to_single(self): def test_no_branches_defaults_to_single(self):
"""No branches list should default to single-branch mode.""" """No branches list should default to single-branch mode."""
@@ -705,9 +705,9 @@ class TestMultiBranchEdgeCases:
contrib = universal_product * branch.intensity * bs[i] contrib = universal_product * branch.intensity * bs[i]
# Branch contribution should not exceed total # Branch contribution should not exceed total
assert np.all( assert np.all(contrib <= total + 1e-10), (
contrib <= total + 1e-10 f"Branch {i} contribution exceeds total at some points"
), f"Branch {i} contribution exceeds total at some points" )
# Branch contribution should be non-negative # Branch contribution should be non-negative
assert np.all(contrib >= 0), f"Branch {i} contribution has negative values" assert np.all(contrib >= 0), f"Branch {i} contribution has negative values"
@@ -759,6 +759,6 @@ class TestMultiBranchEdgeCases:
assert integral > 0, f"Branch {i} has zero integral" assert integral > 0, f"Branch {i} has zero integral"
# Sum of branch integrals should equal total # Sum of branch integrals should equal total
assert np.isclose( assert np.isclose(sum(integrals), total_integral, rtol=1e-6), (
sum(integrals), total_integral, rtol=1e-6 "Sum of branch integrals should equal total integral"
), "Sum of branch integrals should equal total integral" )
+27 -27
View File
@@ -20,12 +20,12 @@ class TestNeutrinoMassPhaseSpaceEffects:
result = ps(W_test) result = ps(W_test)
# Should not produce NaN values # Should not produce NaN values
assert not np.any( assert not np.any(np.isnan(result)), (
np.isnan(result) "Phase space with m_nu=0 should not produce NaN values"
), "Phase space with m_nu=0 should not produce NaN values" )
assert np.all( assert np.all(result > 0), (
result > 0 "Phase space with m_nu=0 should be positive in physical range"
), "Phase space with m_nu=0 should be positive in physical range" )
def test_phase_space_with_nonzero_neutrino_mass(self): def test_phase_space_with_nonzero_neutrino_mass(self):
"""Test that phase space calculation works with non-zero neutrino mass.""" """Test that phase space calculation works with non-zero neutrino mass."""
@@ -34,12 +34,12 @@ class TestNeutrinoMassPhaseSpaceEffects:
result = ps(W_test) result = ps(W_test)
# Should not produce NaN values for energies above threshold # Should not produce NaN values for energies above threshold
assert not np.any( assert not np.any(np.isnan(result)), (
np.isnan(result) "Phase space with m_nu>0 should not produce NaN values above threshold"
), "Phase space with m_nu>0 should not produce NaN values above threshold" )
assert np.all( assert np.all(result > 0), (
result > 0 "Phase space with m_nu>0 should be positive above threshold"
), "Phase space with m_nu>0 should be positive above threshold" )
def test_phase_space_with_neutrino_mass_near_endpoint(self): def test_phase_space_with_neutrino_mass_near_endpoint(self):
"""Test that phase space calculation handles energies near endpoint with neutrino mass.""" """Test that phase space calculation handles energies near endpoint with neutrino mass."""
@@ -48,18 +48,18 @@ class TestNeutrinoMassPhaseSpaceEffects:
# Test energies where W0-W > m_nu (should be finite) # Test energies where W0-W > m_nu (should be finite)
W_above_threshold = np.array([4.8]) # W0-W = 0.2 > m_nu=0.1 W_above_threshold = np.array([4.8]) # W0-W = 0.2 > m_nu=0.1
result_above = ps(W_above_threshold) result_above = ps(W_above_threshold)
assert not np.any( assert not np.any(np.isnan(result_above)), (
np.isnan(result_above) "Should produce finite value above threshold"
), "Should produce finite value above threshold" )
# Test energies where W0-W < m_nu (should be handled properly) # Test energies where W0-W < m_nu (should be handled properly)
# With our fix, this should return 0 instead of NaN # With our fix, this should return 0 instead of NaN
W_below_threshold = np.array([4.95]) # W0-W = 0.05 < m_nu=0.1 W_below_threshold = np.array([4.95]) # W0-W = 0.05 < m_nu=0.1
result_below = ps(W_below_threshold) result_below = ps(W_below_threshold)
# After our fix, NaN values should be replaced with 0 # After our fix, NaN values should be replaced with 0
assert np.all(result_below == 0.0) or np.all( assert np.all(result_below == 0.0) or np.all(np.isnan(result_below)), (
np.isnan(result_below) "Should handle below-threshold energies properly (either 0 or NaN)"
), "Should handle below-threshold energies properly (either 0 or NaN)" )
def test_spectrum_config_with_neutrino_mass(self): def test_spectrum_config_with_neutrino_mass(self):
"""Test that SpectrumConfig accepts and stores neutrino mass parameter.""" """Test that SpectrumConfig accepts and stores neutrino mass parameter."""
@@ -72,9 +72,9 @@ class TestNeutrinoMassPhaseSpaceEffects:
e_step_MeV=0.001, e_step_MeV=0.001,
neutrino_mass_MeV=0.01, neutrino_mass_MeV=0.01,
) )
assert ( assert config.neutrino_mass_MeV == 0.01, (
config.neutrino_mass_MeV == 0.01 "SpectrumConfig should store neutrino mass parameter"
), "SpectrumConfig should store neutrino mass parameter" )
def test_beta_spectrum_with_neutrino_mass(self): def test_beta_spectrum_with_neutrino_mass(self):
"""Test that BetaSpectrum works with neutrino mass in configuration.""" """Test that BetaSpectrum works with neutrino mass in configuration."""
@@ -96,12 +96,12 @@ class TestNeutrinoMassPhaseSpaceEffects:
result = spectrum(W) result = spectrum(W)
# Should not produce NaN values # Should not produce NaN values
assert not np.any( assert not np.any(np.isnan(result)), (
np.isnan(result) "BetaSpectrum with neutrino mass should not produce NaN values"
), "BetaSpectrum with neutrino mass should not produce NaN values" )
assert np.all( assert np.all(result >= 0), (
result >= 0 "BetaSpectrum with neutrino mass should be non-negative"
), "BetaSpectrum with neutrino mass should be non-negative" )
class TestNeutrinoMassCLIIntegration: class TestNeutrinoMassCLIIntegration:
+6 -6
View File
@@ -56,9 +56,9 @@ class TestNeutrinoMassPhaseSpace:
val_massive = ps_massive(W_near_endpoint)[0] val_massive = ps_massive(W_near_endpoint)[0]
assert not np.isnan(val_massive), "Should produce finite value" assert not np.isnan(val_massive), "Should produce finite value"
assert ( assert val_massive < val_zero, (
val_massive < val_zero "Massive neutrino must suppress spectrum near endpoint"
), "Massive neutrino must suppress spectrum near endpoint" )
class TestCLIArguments: class TestCLIArguments:
@@ -84,6 +84,6 @@ class TestCLIArguments:
parser = _build_parser() parser = _build_parser()
args = parser.parse_args(["--nuclide", "Tc99"]) args = parser.parse_args(["--nuclide", "Tc99"])
assert ( assert args.neutrino_mass is None, (
args.neutrino_mass is None "unset --neutrino-mass must parse as None (not a value)"
), "unset --neutrino-mass must parse as None (not a value)" )