Skip to content

BUG: PriorDict: Missing conversion function will silently ignore Constraints #1098

Description

@AlexandreGoettel

Describe the bug
When sampling from a PriorDict that contains Constraints, if that PriorDict does not have a conversion function, the Constraints will silently be ignored. The problem is not the ignoring, but the fact that it is silent.

To Reproduce
In the context of a GW231123 analysis with NRSur7dq4, you might have:

priors = bilby.core.prior.PriorDict({"total_mass": bilby.core.prior.Constraint(name='total_mass', minimum=60, maximum=400), "chirp_mass": bilby.gw.prior.UniformInComponentsChirpMass(minimum=85, maximum=194.62, name='chirp_mass'), "mass_ratio": bilby.gw.prior.UniformInComponentsMassRatio(minimum=0.166666667, maximum=1.0, name='mass_ratio')})
priors.sample()  # ---> will contain invalid samples

Error message
N/A

Expected behavior / Suggested solution (optional)
I would suggest adding a simple warning in case a constraint is being ignored.

Environment (please complete the following information):

  • Bilby version: 2.6.0
  • Installation method [e.g. conda, pip, source]: conda

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions