fix: use underscores in branch names for CSV headers

This commit is contained in:
2026-07-03 15:10:10 +03:00
parent a7eef7bc20
commit c2795bf86e
2 changed files with 17 additions and 16 deletions
+12 -11
View File
@@ -467,8 +467,8 @@ class TestMultiBranchCSVExport:
assert "total_spectrum" in df.columns
# Should have per-branch spectrum columns (intensity/endpoint/transition are in the header)
assert "branch 1" in df.columns
assert "branch 2" in df.columns
assert "branch_1_spectrum" in df.columns
assert "branch_2_spectrum" in df.columns
# Should NOT have repeated per-branch metadata columns
assert "branch_1_intensity" not in df.columns
@@ -503,6 +503,7 @@ class TestMultiBranchCSVExport:
df = pd.read_csv(csv_path, comment="#")
assert "total_spectrum" in df.columns
assert "branch_1_spectrum" in df.columns
assert "Fermi" in df.columns
@@ -659,9 +660,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."""
@@ -726,9 +727,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"
@@ -778,6 +779,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"
)