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

DEV: make sure all priors return float when needed #848

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

ColmTalbot
Copy link
Collaborator

For a long time, some prior classes have cast inputs to numpy arrays this MR removes that behaviour and adds a test to make sure that sampling and evaluating the CDF do not cast to array.

This caused an error when evaluating the CDF many times and then combining the results.

I also streamlined some other behaviour in applying prior constraints that were originally flagged by @cjhaster.

I noticed that the Fermi-Dirac CDF hadn't been implemented for some reason so I added that and added to the CI test suite.
Finally, there was an issue with sampling from joint distributions where the results could be returned out of order.

Copied from https://git.ligo.org/lscsoft/bilby/-/merge_requests/1285

@ColmTalbot ColmTalbot added bug Something isn't working 10-100 lines priors labels Nov 1, 2024
@ColmTalbot ColmTalbot changed the title Fix symmetric log uniform DEV: make sure all priors return float when needed Nov 1, 2024
@mj-will mj-will added this to the 2.5.0 milestone Nov 14, 2024
@mattpitkin mattpitkin self-requested a review February 4, 2025 14:28
@mattpitkin
Copy link
Collaborator

I've double checked the Fermi-Dirac prior CDF and it gives the correct expected result.

@ColmTalbot ColmTalbot requested a review from mj-will February 4, 2025 15:24
Copy link
Collaborator

@mj-will mj-will left a comment

Choose a reason for hiding this comment

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

LGTM, I just have a couple of questions before I approve.

bilby/core/prior/slabspike.py Show resolved Hide resolved
Comment on lines +863 to +868
for names in joint.values():
values = list()
for key in names:
values = np.concatenate([values, result[key]])
for key, value in zip(names, values):
result[key] = value
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you help me understand what this loop is doing? I'm finding the logic of this part a bit hard to follow, it might benefit from a comment.

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1

def test_cdf_float_with_float_input(self):
for prior in self.priors:
if (
bilby.core.prior.JointPrior in prior.__class__.__mro__
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this test skipped for JointPriors with no finite upper bound?

Copy link
Collaborator

@asb5468 asb5468 left a comment

Choose a reason for hiding this comment

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

Left a few questions in the code. Wondering what github will do when I press "submit review" with "request changes" chosen.

@mj-will
Copy link
Collaborator

mj-will commented Feb 10, 2025

@ColmTalbot it looks like there are conflicts following #849

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
10-100 lines bug Something isn't working priors
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants