Merged
Conversation
Owner
jessegrabowski
commented
Dec 13, 2025
- Fix bug where loss functions that return scalars would raise
- Don't square the objective of scalar loss function
- Add tests for jax functions
- Add jax tests
There was a problem hiding this comment.
Pull request overview
This PR improves minimization reporting by fixing a bug where scalar loss functions would raise errors and adds comprehensive JAX integration tests. The changes remove the incorrect squaring of objective values and properly handle JAX arrays and other array-like return values.
Key Changes:
- Fixed
update_progressbarmethod to properly handle scalar and array return values from objective functions - Added comprehensive JAX integration tests covering minimize, root, and basinhopping functions
- Added JAX as a conda environment dependency
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
better_optimize/wrapper.py |
Fixed the update_progressbar method to use np.asarray for converting values, properly distinguish between root-finding (uses norm) and minimization (requires scalar), and removed incorrect squaring of objective values |
tests/test_jax_integration.py |
Added comprehensive tests for JAX array compatibility with minimize, root, and basinhopping functions |
conda_envs/better_optimize.yml |
Added JAX as a dependency for testing JAX integration |
After a thorough review of the code changes, I found no issues. The implementation is correct, follows best practices, and the tests are comprehensive. The changes successfully address all stated goals in the PR description.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.