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

BUG: make get_cosmology constistent with set_cosmology #828

Merged
merged 7 commits into from
Nov 2, 2024

Conversation

mj-will
Copy link
Collaborator

@mj-will mj-will commented Oct 8, 2024

As it stands, get_cosmology does not support the same inputs as set_cosmology despite what the doc-string implies.

This PR moves the logic from set_cosmology to get_cosmology. The former now just calls the latter rather than having duplicate logic.

@mj-will
Copy link
Collaborator Author

mj-will commented Oct 8, 2024

I don't think the change I've made to support braces ({...}) is particularly robust, since something like {'a': (1, 2)} won't work, I think. I'll try to think of a better way of doing this but I'm open to suggestions.

@ColmTalbot
Copy link
Collaborator

I don't think the change I've made to support braces ({...}) is particularly robust, since something like {'a': (1, 2)} won't work, I think. I'll try to think of a better way of doing this but I'm open to suggestions.

Yeah, it won't work with nested cases. I don't think there is much point trying to go much deeper with string parsing. I'm happy to get this in, but I would vote to document better that for complex cases, the json version is much more robust.

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.

I think this is good in general, and probably a safe change. I'm trying to figure out if there are any currently valid prior specifications that will behave differently after this change?

...(..., foo={a: 1}, ...)

Returns the same value as before with this change. I can't think of any other versions that might have changed at this stage. Maybe if there is a single { in an argument.

This has also solved a longer-running issue with latex labels, e.g.,

...(..., latex_label="H_{0, 1}", ...)

The following still fails, but it feels a bit contrived.

...(..., latex_label="H^{0, 2}_{0, 1}", ...)

bilby/core/prior/base.py Outdated Show resolved Hide resolved
test/core/prior/dict_test.py Show resolved Hide resolved
@mj-will mj-will added bug Something isn't working cosmology labels Oct 9, 2024
@mj-will
Copy link
Collaborator Author

mj-will commented Oct 25, 2024

@ColmTalbot what do you think about getting this into 2.4.0?

@ColmTalbot
Copy link
Collaborator

Yeah, I think we should get a version of this in.

@ColmTalbot ColmTalbot added this to the 2.4.0 milestone Oct 25, 2024
@mj-will mj-will marked this pull request as ready for review October 25, 2024 15:39
@mj-will mj-will merged commit 442f747 into bilby-dev:main Nov 2, 2024
10 checks passed
@mj-will mj-will deleted the cosmology-fix branch November 2, 2024 12:48
JasperMartins pushed a commit to JasperMartins/bilby that referenced this pull request Nov 5, 2024
…#828)

* BUG: make `get_cosmology` constistent with `set_cosmology`

* TST: add prior dict test for cosmo parameters

* BUG: handle `{...}` in prior repr

* TST: update asserts for cosmo test

* MAINT: apply Colm's suggestions

* TST: check specific value of dl

* TST: add comment about values
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cosmology
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants