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

make fun optional when fun_and_jac is provided #567

Merged
merged 8 commits into from
Mar 20, 2025

Conversation

gauravmanmode
Copy link
Contributor

Closes #518

Proposed Solution

if fun_and_jac is not None, and fun is not provided, set fun from fun_and_jac.
Also adjusted the docs.
I have added a test also.

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Copy link

codecov bot commented Mar 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Files with missing lines Coverage Δ
...imagic/optimization/create_optimization_problem.py 88.18% <100.00%> (+0.20%) ⬆️
🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@janosg
Copy link
Member

janosg commented Mar 14, 2025

Hi @gauravmanmode, thanks for the PR.

We want to support this, but there is one edge case that makes it slightly harder: As you can see here, jac or fun_and_jac can be a list of callables if users want to switch seamlessly between scalar and least_squares optimizers. In that case we would have to select the correct entry from the list before we can call split_fun_and_jac. But at the point where you are handling this case we don't even know yet which entry we would need.

My plan was to wait until version 0.6 where we can remove a lot of deprecated code that currently limits the order in which we can process user inputs.

But we can keep your PR as a step in the right direction if you raise an error for the (very rare) case that fun_and_jac is a list.

@gauravmanmode
Copy link
Contributor Author

you are right. i dont know how to handle this. since you said it is a rare case, i have raised a error and added a test.

Copy link
Member

@janosg janosg left a comment

Choose a reason for hiding this comment

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

Thanks @gauravmanmode, this is looking really good now. I only had a few small suggestions that should be very quick to address.

@gauravmanmode
Copy link
Contributor Author

@janosg thanks for the suggestions. i hope this resolves them.

Copy link
Member

@janosg janosg left a comment

Choose a reason for hiding this comment

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

Thanks a lot; This is good to merge now!

@janosg janosg merged commit c85209e into optimagic-dev:main Mar 20, 2025
21 checks passed
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.

Make fun optional if fun_and_jac is provided
2 participants