docs: update documentation files and fix linting issues

This commit is contained in:
2026-07-07 13:32:48 +03:00
parent 9bf1e1333e
commit be3e288e0d
27 changed files with 423 additions and 250 deletions
+6 -2
View File
@@ -13,7 +13,9 @@ except ImportError:
DetectorResponse = None # type: ignore[misc, assignment]
@pytest.mark.skipif(DetectorResponse is None, reason="DetectorResponse not yet implemented")
@pytest.mark.skipif(
DetectorResponse is None, reason="DetectorResponse not yet implemented"
)
class TestFactoryMethods:
"""Test convenience factory methods."""
@@ -56,7 +58,9 @@ class TestFactoryMethods:
assert len(resp.calibration_energies) == 3
@pytest.mark.skipif(DetectorResponse is None, reason="DetectorResponse not yet implemented")
@pytest.mark.skipif(
DetectorResponse is None, reason="DetectorResponse not yet implemented"
)
class TestEdgeCases:
"""Test edge cases and error handling."""
+17 -7
View File
@@ -18,15 +18,20 @@ class TestExchangeAPI:
result = ex(np.array([2.0]))
assert isinstance(result, np.ndarray)
class TestExchangeProperties:
@pytest.mark.property
@pytest.mark.parametrize("W", [
[2.0],
np.linspace(1.01, 6.0, 50),
])
@pytest.mark.parametrize(
"W",
[
[2.0],
np.linspace(1.01, 6.0, 50),
],
)
def test_positive(self, W):
ex = ExchangeCorrection(Z=92)
from tests.common.test_property_tests import _test_positive_values
_test_positive_values(ex, W, component_name="ExchangeCorrection")
@pytest.mark.quality
@@ -35,13 +40,18 @@ class TestExchangeProperties:
ex = ExchangeCorrection(Z=30)
W = np.linspace(1.1, 3.0, n)
from tests.common.test_property_tests import _test_output_shape_preserved
_test_output_shape_preserved(ex, W, component_name="ExchangeCorrection")
@pytest.mark.quality
@pytest.mark.parametrize("W", [
np.linspace(1.01, 6.0, 50),
])
@pytest.mark.parametrize(
"W",
[
np.linspace(1.01, 6.0, 50),
],
)
def test_no_nan(self, W):
ex = ExchangeCorrection(Z=92)
from tests.common.test_property_tests import _test_no_nan_across_range
_test_no_nan_across_range(ex, W, component_name="ExchangeCorrection")
+19 -9
View File
@@ -26,19 +26,24 @@ class TestFermiAPI:
ff = FermiFunction(Z=20, A=40)
assert "FermiFunction" in repr(ff)
class TestFermiProperties:
"""Shared property tests for FermiFunction."""
@pytest.mark.property
@pytest.mark.parametrize("W", [
[1.5],
[1.1, 2.0, 3.0],
np.linspace(1.01, 5.0, 20),
])
@pytest.mark.parametrize(
"W",
[
[1.5],
[1.1, 2.0, 3.0],
np.linspace(1.01, 5.0, 20),
],
)
def test_positive(self, W):
"""F₀ must be positive everywhere — it's a probability enhancement factor."""
ff = FermiFunction(Z=92, A=238) # Uranium — extreme case
from tests.common.test_property_tests import _test_positive_values
_test_positive_values(ff, W, component_name="FermiFunction")
@pytest.mark.quality
@@ -48,17 +53,22 @@ class TestFermiProperties:
ff = FermiFunction(Z=20, A=40)
W = np.linspace(1.1, 3.0, n)
from tests.common.test_property_tests import _test_output_shape_preserved
_test_output_shape_preserved(ff, W, component_name="FermiFunction")
@pytest.mark.quality
@pytest.mark.parametrize("W", [
np.linspace(1.01, 6.0, 50),
np.linspace(1.001, 10.0, 100),
])
@pytest.mark.parametrize(
"W",
[
np.linspace(1.01, 6.0, 50),
np.linspace(1.001, 10.0, 100),
],
)
def test_no_nan(self, W):
"""For very heavy nuclei, the loggamma implementation must not overflow."""
ff = FermiFunction(Z=92, A=238)
from tests.common.test_property_tests import _test_no_nan_across_range
_test_no_nan_across_range(ff, W, component_name="FermiFunction")
@pytest.mark.quality
+19 -8
View File
@@ -23,15 +23,20 @@ class TestFiniteSizeL0API:
fs = FiniteSizeL0(Z=20, A=40)
assert "FiniteSizeL0" in repr(fs)
class TestFiniteSizeL0Properties:
@pytest.mark.property
@pytest.mark.parametrize("W", [
[2.0],
np.linspace(1.05, 6.0, 20),
])
@pytest.mark.parametrize(
"W",
[
[2.0],
np.linspace(1.05, 6.0, 20),
],
)
def test_positive(self, W):
fs = FiniteSizeL0(Z=92, A=238)
from tests.common.test_property_tests import _test_positive_values
_test_positive_values(fs, W, component_name="FiniteSizeL0")
@pytest.mark.quality
@@ -40,6 +45,7 @@ class TestFiniteSizeL0Properties:
fs = FiniteSizeL0(Z=20, A=40)
W = np.linspace(1.1, 3.0, n)
from tests.common.test_property_tests import _test_output_shape_preserved
_test_output_shape_preserved(fs, W, component_name="FiniteSizeL0")
@@ -59,13 +65,17 @@ class TestChargeDistributionUAPI:
class TestChargeDistributionUProperties:
@pytest.mark.property
@pytest.mark.parametrize("W", [
[2.0],
np.linspace(1.1, 5.0, 10),
])
@pytest.mark.parametrize(
"W",
[
[2.0],
np.linspace(1.1, 5.0, 10),
],
)
def test_non_negative(self, W):
u = ChargeDistributionU(Z=20, A=40)
from tests.common.test_property_tests import _test_non_negative_values
_test_non_negative_values(u, W, component_name="ChargeDistributionU")
@pytest.mark.quality
@@ -74,4 +84,5 @@ class TestChargeDistributionUProperties:
u = ChargeDistributionU(Z=20, A=40)
W = np.linspace(1.1, 3.0, n)
from tests.common.test_property_tests import _test_output_shape_preserved
_test_output_shape_preserved(u, W, component_name="ChargeDistributionU")
+19 -9
View File
@@ -21,19 +21,24 @@ class TestPhaseSpaceAPI:
result = ps(np.array([3.0]))
assert isinstance(result, np.ndarray)
class TestPhaseSpaceProperties:
"""Shared property tests for PhaseSpace."""
@pytest.mark.property
@pytest.mark.parametrize("W", [
[1.5],
[1.1, 2.0, 3.0],
np.linspace(1.01, 4.9, 20),
])
@pytest.mark.parametrize(
"W",
[
[1.5],
[1.1, 2.0, 3.0],
np.linspace(1.01, 4.9, 20),
],
)
def test_non_negative(self, W):
"""Phase space must be non-negative (zero at boundaries)."""
ps = PhaseSpace(W0=5.0)
from tests.common.test_property_tests import _test_non_negative_values
_test_non_negative_values(ps, W, component_name="PhaseSpace")
@pytest.mark.quality
@@ -43,15 +48,20 @@ class TestPhaseSpaceProperties:
ps = PhaseSpace(W0=5.0)
W = np.linspace(1.1, 4.9, n)
from tests.common.test_property_tests import _test_output_shape_preserved
_test_output_shape_preserved(ps, W, component_name="PhaseSpace")
@pytest.mark.quality
@pytest.mark.parametrize("W", [
np.linspace(1.01, 4.99, 50),
np.linspace(1.001, 4.999, 100),
])
@pytest.mark.parametrize(
"W",
[
np.linspace(1.01, 4.99, 50),
np.linspace(1.001, 4.999, 100),
],
)
def test_stability(self, W):
"""Phase space must be stable across the full energy range."""
ps = PhaseSpace(W0=5.0)
from tests.common.test_property_tests import _test_full_range_stability
_test_full_range_stability(ps, W, component_name="PhaseSpace")
+18 -8
View File
@@ -39,13 +39,17 @@ class TestRadiativeAPI:
class TestRadiativeProperties:
@pytest.mark.property
@pytest.mark.parametrize("W", [
[2.0],
np.linspace(1.1, 4.9, 20),
])
@pytest.mark.parametrize(
"W",
[
[2.0],
np.linspace(1.1, 4.9, 20),
],
)
def test_positive(self, W):
rc = RadiativeCorrection(W0=5.0)
from tests.common.test_property_tests import _test_positive_values
_test_positive_values(rc, W, component_name="RadiativeCorrection")
@pytest.mark.quality
@@ -54,6 +58,7 @@ class TestRadiativeProperties:
rc = RadiativeCorrection(W0=5.0)
W = np.linspace(1.1, 4.9, n)
from tests.common.test_property_tests import _test_output_shape_preserved
_test_output_shape_preserved(rc, W, component_name="RadiativeCorrection")
@pytest.mark.quality
@@ -63,17 +68,22 @@ class TestRadiativeProperties:
rc = RadiativeCorrection(W0=W0)
W = np.linspace(1.1, min(9.9, W0 - 0.01), 20)
from tests.common.test_property_tests import _test_no_nan_across_range
_test_no_nan_across_range(rc, W, component_name=f"RadiativeCorrection(W0={W0})")
@pytest.mark.quality
@pytest.mark.parametrize("W", [
np.linspace(1.0001, 4.9999, 200),
np.linspace(1.001, 9.99, 100),
])
@pytest.mark.parametrize(
"W",
[
np.linspace(1.0001, 4.9999, 200),
np.linspace(1.001, 9.99, 100),
],
)
def _test_full_range_stability(self, W):
"""Entire energy range from threshold to endpoint must be free of NaN/inf."""
rc = RadiativeCorrection(W0=5.0, Z=92, use_endpoint_resummation=True)
from tests.common.test_property_tests import _test_full_range_stability
_test_full_range_stability(rc, W, component_name="RadiativeCorrection(Z=92)")
@pytest.mark.quality
+10 -4
View File
@@ -26,16 +26,21 @@ class TestScreeningAPI:
sc = ScreeningCorrection(ff)
assert "Screening" in repr(sc)
class TestScreeningProperties:
@pytest.mark.property
@pytest.mark.parametrize("W", [
[2.0],
np.linspace(1.02, 3.0, 20),
])
@pytest.mark.parametrize(
"W",
[
[2.0],
np.linspace(1.02, 3.0, 20),
],
)
def test_positive(self, W):
ff = FermiFunction(Z=40, A=95)
sc = ScreeningCorrection(ff)
from tests.common.test_property_tests import _test_positive_values
_test_positive_values(sc, W, component_name="ScreeningCorrection")
@pytest.mark.quality
@@ -45,4 +50,5 @@ class TestScreeningProperties:
sc = ScreeningCorrection(ff)
W = np.linspace(1.1, 3.0, n)
from tests.common.test_property_tests import _test_output_shape_preserved
_test_output_shape_preserved(sc, W, component_name="ScreeningCorrection")
+3 -3
View File
@@ -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: