-
Notifications
You must be signed in to change notification settings - Fork 79
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] Fix passing mode_array in injection-waveform-arguments #820
Open
lorenzopompili00
wants to merge
8
commits into
bilby-dev:main
Choose a base branch
from
lorenzopompili00:fix_injection_mode_array
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c550ae8
Fix passing mode_array in injection-waveform-arguments
lorenzo-pompili 4d85792
Add name to authors.md
lorenzo-pompili f3652b6
Put conversion inside if statement
lorenzo-pompili d0ced8d
Add try/except
lorenzo-pompili ba16abe
Typo
lorenzo-pompili 29c325c
Merge branch 'main' into fix_injection_mode_array
ColmTalbot 8d93f18
Add more informative error message
lorenzo-pompili 97f82cc
Add safe_cast_mode_to_int
lorenzo-pompili File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,4 +103,5 @@ Martin White | |
Peter Tsun-Ho Pang | ||
Alexandre Sebastien Goettel | ||
Ann-Kristin Malz | ||
Lorenzo Pompili | ||
Sean Hibbitt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the motivation for wrapping
mode[0]
inside anint
? I have the following concern in mind: saymode[0]
in reality is zero, but due to some numerical issues it gets set to1.999999
(or something like that). This would makeint(mode[0]) = 1
, which is totally different.In any case, I suggest casting to
int
(taking consistency checks like the above into account) when the mode array is set.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lalsimulation is pretty strongly typed, the arguments have to be forced into int. We could be stricter, but sometimes Python will convert ints to float by association with other floats.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is done differently for the gwsignal case
I'm not too worried by the different implementations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow-up question; why do we need this now when we didn't before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can tell this has always been an issue, the use-case in which one gets this error (requesting different mode arrays for the injection and recovery waveform via
bilby_pipe
) is just not very frequent, I suppose.IMO the main issue is in
bilby_pipe
, which does not parse something likeas a list of lists in ints, but as a list of lists of strings, which ends up triggering the error above (see also https://git.ligo.org/lscsoft/bilby_pipe/-/issues/293). However there are some unit tests there which break if this behavior is changed (see https://git.ligo.org/lscsoft/bilby_pipe/-/merge_requests/585), which is the motivation for wrapping
mode[0]
,mode[1]
to int directly inbilby
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given @adivijaykumar's concern, would it be safer to have a function that only maps allowed types to
int
? I was thinking of something like this, which could then be called usingmap
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, I am happy do add this. What do you think would be a good place for this? Maybe https://github.com/bilby-dev/bilby/blob/main/bilby/core/utils/conversion.py?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I'd consider renaming it to be more specific (something like
safe_cast_mode_to_int
or similar) and putting it inbilby.gw.utils
. I thinkconversions
is more for conversions between parameters (I also thinkbilby.core.utils.conversion
might get moved/deprecated at some point, since they're GW functions incore
).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I added the function you suggested together with some tests