diff --git a/tests/physics/test_multi_branch.py b/tests/physics/test_multi_branch.py index 9491b79..f45661c 100644 --- a/tests/physics/test_multi_branch.py +++ b/tests/physics/test_multi_branch.py @@ -637,9 +637,9 @@ class TestMultiBranchEdgeCases: W, _ = spectrum.get_energy_grid(config) values = spectrum(W) - assert np.all( - np.isfinite(values) - ), "High-Z multi-branch must not produce NaN/inf" + assert np.all(np.isfinite(values)), ( + "High-Z multi-branch must not produce NaN/inf" + ) def test_no_branches_defaults_to_single(self): """No branches list should default to single-branch mode.""" @@ -705,9 +705,9 @@ class TestMultiBranchEdgeCases: contrib = universal_product * branch.intensity * bs[i] # Branch contribution should not exceed total - assert np.all( - contrib <= total + 1e-10 - ), f"Branch {i} contribution exceeds total at some points" + assert np.all(contrib <= total + 1e-10), ( + f"Branch {i} contribution exceeds total at some points" + ) # Branch contribution should be non-negative 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" # Sum of branch integrals should equal total - assert np.isclose( - sum(integrals), total_integral, rtol=1e-6 - ), "Sum of branch integrals should equal total integral" + assert np.isclose(sum(integrals), total_integral, rtol=1e-6), ( + "Sum of branch integrals should equal total integral" + ) diff --git a/tests/physics/test_neutrino_mass_effects.py b/tests/physics/test_neutrino_mass_effects.py index 67bfafb..ea72d69 100644 --- a/tests/physics/test_neutrino_mass_effects.py +++ b/tests/physics/test_neutrino_mass_effects.py @@ -20,12 +20,12 @@ class TestNeutrinoMassPhaseSpaceEffects: result = ps(W_test) # Should not produce NaN values - assert not np.any( - np.isnan(result) - ), "Phase space with m_nu=0 should not produce NaN values" - assert np.all( - result > 0 - ), "Phase space with m_nu=0 should be positive in physical range" + assert not np.any(np.isnan(result)), ( + "Phase space with m_nu=0 should not produce NaN values" + ) + assert np.all(result > 0), ( + "Phase space with m_nu=0 should be positive in physical range" + ) def test_phase_space_with_nonzero_neutrino_mass(self): """Test that phase space calculation works with non-zero neutrino mass.""" @@ -34,12 +34,12 @@ class TestNeutrinoMassPhaseSpaceEffects: result = ps(W_test) # Should not produce NaN values for energies above threshold - assert not np.any( - np.isnan(result) - ), "Phase space with m_nu>0 should not produce NaN values above threshold" - assert np.all( - result > 0 - ), "Phase space with m_nu>0 should be positive above threshold" + assert not np.any(np.isnan(result)), ( + "Phase space with m_nu>0 should not produce NaN values above threshold" + ) + assert np.all(result > 0), ( + "Phase space with m_nu>0 should be positive above threshold" + ) def test_phase_space_with_neutrino_mass_near_endpoint(self): """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) W_above_threshold = np.array([4.8]) # W0-W = 0.2 > m_nu=0.1 result_above = ps(W_above_threshold) - assert not np.any( - np.isnan(result_above) - ), "Should produce finite value above threshold" + assert not np.any(np.isnan(result_above)), ( + "Should produce finite value above threshold" + ) # Test energies where W0-W < m_nu (should be handled properly) # 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 result_below = ps(W_below_threshold) # After our fix, NaN values should be replaced with 0 - assert np.all(result_below == 0.0) or np.all( - np.isnan(result_below) - ), "Should handle below-threshold energies properly (either 0 or NaN)" + assert np.all(result_below == 0.0) or np.all(np.isnan(result_below)), ( + "Should handle below-threshold energies properly (either 0 or NaN)" + ) def test_spectrum_config_with_neutrino_mass(self): """Test that SpectrumConfig accepts and stores neutrino mass parameter.""" @@ -72,9 +72,9 @@ class TestNeutrinoMassPhaseSpaceEffects: e_step_MeV=0.001, neutrino_mass_MeV=0.01, ) - assert ( - config.neutrino_mass_MeV == 0.01 - ), "SpectrumConfig should store neutrino mass parameter" + assert config.neutrino_mass_MeV == 0.01, ( + "SpectrumConfig should store neutrino mass parameter" + ) def test_beta_spectrum_with_neutrino_mass(self): """Test that BetaSpectrum works with neutrino mass in configuration.""" @@ -96,12 +96,12 @@ class TestNeutrinoMassPhaseSpaceEffects: result = spectrum(W) # Should not produce NaN values - assert not np.any( - np.isnan(result) - ), "BetaSpectrum with neutrino mass should not produce NaN values" - assert np.all( - result >= 0 - ), "BetaSpectrum with neutrino mass should be non-negative" + assert not np.any(np.isnan(result)), ( + "BetaSpectrum with neutrino mass should not produce NaN values" + ) + assert np.all(result >= 0), ( + "BetaSpectrum with neutrino mass should be non-negative" + ) class TestNeutrinoMassCLIIntegration: diff --git a/tests/quality/test_neutrino_mass_cli.py b/tests/quality/test_neutrino_mass_cli.py index 88eddb3..b8f5236 100644 --- a/tests/quality/test_neutrino_mass_cli.py +++ b/tests/quality/test_neutrino_mass_cli.py @@ -56,9 +56,9 @@ class TestNeutrinoMassPhaseSpace: val_massive = ps_massive(W_near_endpoint)[0] assert not np.isnan(val_massive), "Should produce finite value" - assert ( - val_massive < val_zero - ), "Massive neutrino must suppress spectrum near endpoint" + assert val_massive < val_zero, ( + "Massive neutrino must suppress spectrum near endpoint" + ) class TestCLIArguments: @@ -84,6 +84,6 @@ class TestCLIArguments: parser = _build_parser() args = parser.parse_args(["--nuclide", "Tc99"]) - assert ( - args.neutrino_mass is None - ), "unset --neutrino-mass must parse as None (not a value)" + assert args.neutrino_mass is None, ( + "unset --neutrino-mass must parse as None (not a value)" + )