Registry / ai-ml / better-optimize

better-optimize

JSON →
library0.4.2pypypi✓ verified 85d ago

A drop-in replacement for scipy.optimize functions with quality-of-life improvements, such as automatic gradient computation via JAX, progress bars, and early stopping. Current version is 0.4.1, released in 2025. The project is under active development with monthly releases.

pip install better-optimize
INSTALL
IMPORT
SIG · BETTER-OPTIMIZE
B
better-optimize
ai-mlpythonv0.4.2
Install
11.5s avg
Import
3329ms
Disk
305MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.3.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 2.756s · 320.6MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 11.5s · import 2.570s · 308MB
305MB installed
● package 305MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

minimize
from better_optimize import minimize
from scipy.optimize import minimize
better-optimize provides a drop-in replacement; using scipy's version won't get the QoL improvements.

Minimize the Rosenbrock function using BFGS. Note: JAX arrays are used for automatic differentiation.

import jax.numpy as jnp from better_optimize import minimize def rosen(x): return (1 - x[0])**2 + 100 * (x[1] - x[0]**2)**2 x0 = jnp.array([0.0, 0.0]) res = minimize(rosen, x0, method='BFGS') print(res.x)
Debug
Known issues
breakingThis library requires Python >=3.12. Attempting to install on older versions will fail.
fix
Upgrade Python to 3.12 or later.
affects: 0.4.1
gotchaThe library expects JAX arrays as inputs when using JAX-based gradients. Using NumPy arrays may cause errors or unexpected behavior.
fix
Convert NumPy arrays to JAX arrays via jnp.array(your_array).
affects: 0.3.0+
deprecatedThe 'callback' parameter in earlier versions was renamed to 'progress_callback'. The old name still works but will be removed in 0.5.0.
fix
Use 'progress_callback' instead of 'callback'.
affects: 0.3.0 - 0.4.1
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'better_optimize'
Library not installed or installed under a different name.
fix
Run 'pip install better-optimize' and ensure you are using the correct import name 'better_optimize' (underscore).
TypeError: expected JAX array, got numpy.ndarray
Passing NumPy arrays directly to functions that expect JAX arrays.
fix
Convert inputs to JAX arrays: x_jax = jnp.array(x_numpy).
Upgrade
Version history
0.4.2latest on PyPI · released May 23, 2026
Audit
Dependencies
scipyrequiredRequired for compatibility with scipy.optimize functions; better-optimize wraps them.
jaxoptionalEnables automatic gradient computation (optional, but recommended for most features).
Agent activity
21 hits · last 30 days
node
18
OpenAI (training)
1
Resources
better-optimize — pip install better-optimize · libregistry