-
-
Notifications
You must be signed in to change notification settings - Fork 493
Description
Is your feature request related to a problem? Please describe.
The DilutePlanckianRadiationField class in tardis/plasma/radiation_field/planck_rad_field.py has no direct unit tests. It is only exercised indirectly through full simulation regression tests, which makes CodeCov metrics inaccurate and makes it very hard to pinpoint the root cause when a regression test fails.
Describe the solution you'd like
Create a new test file tardis/plasma/radiation_field/tests/test_planck_rad_field.py with focused unit tests for the class. Tests should cover:
- Valid construction with correct temperature and dilution_factor arrays
AssertionErrorraised whenlen(temperature) != len(dilution_factor)AssertionErrorraised when temperature <= 0 KAssertionErrorraised when dilution_factor < 0temperature_kelvinproperty returns correct float valuescalculate_mean_intensity(nu)returnsW × B_nu(T), pinned against regression data- Zero dilution factor produces zero intensity
to_planckian_radiation_field()returns correct type with same temperature
Regression data path should be modified locally so no PR to the regression data repository is needed.
Describe alternatives you've considered
- Continuing to rely on indirect regression tests — rejected because failures are hard to diagnose and coverage metrics remain inaccurate.
- Mocking the Planck function — rejected because testing the actual physical formula against regression data gives stronger guarantees.
Additional context
The class is the foundation of all dilute-LTE and nebular approximation radiation fields in TARDIS. Every simulation using these modes passes through calculate_mean_intensity(). Bonus tests to mention in the PR: test with a geometry object (active shell slicing), verify intensity units are physically correct (erg/s/cm²/Hz/sr), and test against a manually computed Planck function value for a known temperature and frequency.