Skip to content

Add systematic input checking to interaction channels #65

@JostMigenda

Description

@JostMigenda

Using o16eb as an example:

import sntools.interaction_channels.o16eb as o16eb

# Should raise `ValueError` since "xb" is not in `o16eb.possible_flavors`.
# Instead, it currently ignores the input value and returns values for "eb".
c = o16eb.Channel("xb")

# Should raise `ValueError` since 0 MeV is outside of `o16eb.bounds_eNu`.
# Instead, it currently raises `UnboundLocalError` due to an implementation detail.
c.bounds_eE(eNu=0)

In both cases, best practice would be to use the provided values (possible_flavors and bounds_eNu) to get physical values first; that’s why this isn’t an issue in sntools itself. However, if we want to make these interaction channels available as a public API, better input checking would be helpful.

In many cases, this could be tested in the CrossSectionTest base class (e.g. c.bounds_eE(-1) or c.bounds_eE(9999)); but accessing possible_flavors might require some changes to the individual test files.

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