style: canonicalize black formatting on test files
This commit is contained in:
@@ -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(np.isfinite(values)), (
|
assert np.all(
|
||||||
"High-Z multi-branch must not produce NaN/inf"
|
np.isfinite(values)
|
||||||
)
|
), "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(contrib <= total + 1e-10), (
|
assert np.all(
|
||||||
f"Branch {i} contribution exceeds total at some points"
|
contrib <= total + 1e-10
|
||||||
)
|
), 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(sum(integrals), total_integral, rtol=1e-6), (
|
assert np.isclose(
|
||||||
"Sum of branch integrals should equal total integral"
|
sum(integrals), total_integral, rtol=1e-6
|
||||||
)
|
), "Sum of branch integrals should equal total integral"
|
||||||
|
|||||||
@@ -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(np.isnan(result)), (
|
assert not np.any(
|
||||||
"Phase space with m_nu=0 should not produce NaN values"
|
np.isnan(result)
|
||||||
)
|
), "Phase space with m_nu=0 should not produce NaN values"
|
||||||
assert np.all(result > 0), (
|
assert np.all(
|
||||||
"Phase space with m_nu=0 should be positive in physical range"
|
result > 0
|
||||||
)
|
), "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(np.isnan(result)), (
|
assert not np.any(
|
||||||
"Phase space with m_nu>0 should not produce NaN values above threshold"
|
np.isnan(result)
|
||||||
)
|
), "Phase space with m_nu>0 should not produce NaN values above threshold"
|
||||||
assert np.all(result > 0), (
|
assert np.all(
|
||||||
"Phase space with m_nu>0 should be positive above threshold"
|
result > 0
|
||||||
)
|
), "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(np.isnan(result_above)), (
|
assert not np.any(
|
||||||
"Should produce finite value above threshold"
|
np.isnan(result_above)
|
||||||
)
|
), "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(np.isnan(result_below)), (
|
assert np.all(result_below == 0.0) or np.all(
|
||||||
"Should handle below-threshold energies properly (either 0 or NaN)"
|
np.isnan(result_below)
|
||||||
)
|
), "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 config.neutrino_mass_MeV == 0.01, (
|
assert (
|
||||||
"SpectrumConfig should store neutrino mass parameter"
|
config.neutrino_mass_MeV == 0.01
|
||||||
)
|
), "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(np.isnan(result)), (
|
assert not np.any(
|
||||||
"BetaSpectrum with neutrino mass should not produce NaN values"
|
np.isnan(result)
|
||||||
)
|
), "BetaSpectrum with neutrino mass should not produce NaN values"
|
||||||
assert np.all(result >= 0), (
|
assert np.all(
|
||||||
"BetaSpectrum with neutrino mass should be non-negative"
|
result >= 0
|
||||||
)
|
), "BetaSpectrum with neutrino mass should be non-negative"
|
||||||
|
|
||||||
|
|
||||||
class TestNeutrinoMassCLIIntegration:
|
class TestNeutrinoMassCLIIntegration:
|
||||||
|
|||||||
@@ -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 val_massive < val_zero, (
|
assert (
|
||||||
"Massive neutrino must suppress spectrum near endpoint"
|
val_massive < val_zero
|
||||||
)
|
), "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 args.neutrino_mass is None, (
|
assert (
|
||||||
"unset --neutrino-mass must parse as None (not a value)"
|
args.neutrino_mass is None
|
||||||
)
|
), "unset --neutrino-mass must parse as None (not a value)"
|
||||||
|
|||||||
Reference in New Issue
Block a user