8000 Fixing bind mapping with multiple models by phajy · Pull Request #90 · fjebaker/SpectralFitting.jl · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fixing bind mapping with multiple models #90

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

Merged
merged 4 commits into from
May 5, 2024

Conversation

phajy
Copy link
Contributor
@phajy phajy commented Apr 22, 2024

This PR addresses #89 regarding a problem with bind if there are multiple models and datasets.

Once a parameter has been bound to another parameter it must relinquish the parameter number it had before being bound. This means that there is now a gap in the contiguous list of parameter numbers. Larger parameter numbers then need to be shuffled down by one to fill this gap, resulting in a contiguous list of parameters. The problem was that all later parameters in the lit were being decremented by 1 regardless of whether they were larger or not.

A test case has been added to check that bind works as anticipated for multiple models and datasets. Further tests could usefully be added.

Finally, there are lots of debugging println statements that can be removed once we're satisfied the code is working properly.

@phajy phajy changed the title Fixing bin mapping with multiple modls Fixing bind mapping with multiple models Apr 22, 2024
Copy link
Owner
@fjebaker fjebaker left a comment

Choose a reason for hiding this comment

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

Hi @phajy this looks good! I would ask for a few more test cases though, specifically

  • 3 models, 1 bound parameter
  • 3 models (2 the same, 1 different), bind one parameter between the two
  • 2 models, both different, bind a parameter that is only in one model (check it does no-ops okay)

Have you tested it on your use case? Might be worth adding an integration test somewhere too, but maybe that's for a new PR. Let's get this one merged first.

@fjebaker fjebaker linked an issue Apr 22, 2024 that may be closed by this pull request
Copy link
Contributor Author
@phajy phajy left a comment

Choose a reason for hiding this comment

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

I'll add some test cases. Is it OK to use XSPEC models in the test? I want something with more than two parameters but all the current Julia additive models have two parameters. What do you recommend?

@phajy
Copy link
Contributor Author
phajy commented May 3, 2024

I've added some test cases. However, test case 3 suggested above (the no-op case) does not work. If you try to bind a parameter that is not in one of the models _get_index_of_symbol returns an error. Perhaps this function should just return nothing then we can get bind! to ignore nothingss. Not sure how this affects _bind_pairs! though.

Any suggestions?

Copy link
Owner
@fjebaker fjebaker left a comment

Choose a reason for hiding this comment

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

Thanks Andy!

@fjebaker
Copy link
Owner
fjebaker commented May 3, 2024

Well noticed, I think we should address that in a new PR though. This one has the test suite passing so I think it's good to merge.

@phajy
Copy link
Contributor Author
phajy commented May 3, 2024

I should get rid of the debug print statements - do you want me to create a new PR for that?

@fjebaker
Copy link
Owner
fjebaker commented May 3, 2024

I think it's fine just to do it in this PR. If you could add one more commit removing the debug statements 👍

@phajy
Copy link
Contributor Author
phajy commented May 4, 2024

Done! Print statements removed.

Note, however, that the test suite is only passing because I have commented out the code that tests

2 models, both different, bind a parameter that is only in one model (check it does no-ops okay)

because it does not work yet. See #90 (comment) above.

@phajy phajy marked this pull request as ready for review May 4, 2024 20:57
@phajy phajy closed this May 5, 2024
@phajy phajy reopened this May 5, 2024
@phajy
Copy link
Contributor Author
phajy commented May 5, 2024

Sorry, accidentally closed the PR. Happy for you to merge.

@fjebaker fjebaker merged commit b38142d into fjebaker:main May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problem with bind! with multiple models
2 participants
0