Skip to content

Add direct unit tests for DilutePlanckianRadiationField class #3487

@adity1raut

Description

@adity1raut

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
  • AssertionError raised when len(temperature) != len(dilution_factor)
  • AssertionError raised when temperature <= 0 K
  • AssertionError raised when dilution_factor < 0
  • temperature_kelvin property returns correct float values
  • calculate_mean_intensity(nu) returns W × 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions