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

Salt2 ColorLaw function correction #389

Merged

Conversation

ConstanceGanot
Copy link
Contributor

Hi, an error has been found when Pickling/Unpickling objects than contain sncosmo.models Model objects : it updates the SALT2ColorLaw object coefficients (in salt2utils.pyx) and then crash.

It is due to the function __get_new_args__ that has been made for pickling, and that adds an extra value in the coefficients array to return.
I show an illustration of the bug in the picture below, we begin with some coefficients for the colorlaw and then it add 0s.

I replaced ncoeffs, that is be the number of input coefficients +1, to ncoeffs-1 in the __get_new_args__ function.

bug_colorlaw

@benjaminrose
Copy link
Member

Is there a way to add a test, or modify a current test like

def test_salt2colorlaw_pickle():

so that we can make sure this bug is not reintroduced?

@benjaminrose benjaminrose self-assigned this Feb 20, 2024
@ConstanceGanot
Copy link
Contributor Author

I've modified the test function by adding two 0's at the end of the coefficients list, so that the color law is not modified but the number of coefficients is at the maximum. I tested it on both versions and it raised an error on the previous one.

@benjaminrose benjaminrose merged commit a0ca243 into sncosmo:master Feb 21, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants