Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUGFIX: Joint prior subclassing fixes #44

Merged

Conversation

JasperMartins
Copy link
Contributor

This pull request addresses multiple issues with the subclassing of BaseJointPrior lists and their reinitialization from json or dict outlined in #31, implements fixes and also test cases that fail with the old implementation.

The tests uncovered some new issues that required fixes beyond the (current) discussion in #31. The fixes are implemented by moving some of the logic used to re-initialize (subclasses of) BaseJointPriorDist from MultivariateGaussianDist to BaseJointPriorDist.

The tests also uncovered a problem with __eq__ for JointPrior that resulted in __eq__ giving False if the dist keyword does not point to the same instance. This, I felt, was inconsistent with the usage of __eq__ across PriorDict.

One overall change currently applied by this PR is that it is now easier to, by mistake, use a not-subclassed BaseJointPriorDist somewhere. I wonder, however, if the BaseJointPriorDist methods that need be subclassed should not raise an NotImplemented error anyway.

Copy link
Collaborator

@ColmTalbot ColmTalbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @JasperMartins I'm happy with these changes and it looks like they are well covered in tests.

On the point about being able to instantiate the base distribution. We generally haven't been good about making base classes unusable, it would be nice longer term to track down the various places we should either have some kind of abstract base or a bunch of NotImplementedErrors.

@ColmTalbot ColmTalbot requested a review from mattpitkin October 2, 2024 17:02
Copy link
Collaborator

@mattpitkin mattpitkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@ColmTalbot ColmTalbot changed the title Joint prior subclassing fixes BUGFIX: Joint prior subclassing fixes Oct 3, 2024
@ColmTalbot ColmTalbot force-pushed the joint_prior_subclassing_fixes branch from d3da588 to 883662d Compare October 3, 2024 20:18
@mj-will mj-will added the bug Something isn't working label Oct 4, 2024
@ColmTalbot ColmTalbot merged commit ed30e87 into bilby-dev:main Oct 4, 2024
10 checks passed
@mj-will mj-will added this to the 2.4.0 milestone Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants