Errors with `ScipyBoundedMinimize`
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 76
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 1
Description
I tried the following:
```py
from jaxopt import ScipyBoundedMinimize
solver = ScipyBoundedMinimize(fun=state_action_value_jax, method="l-bfgs-b")
def T_jax(v, model):
def update_v(carry, y):
b = jnp.array((1e-5, y))
result = solver.run(y, bounds=b, data=(y, v, model)).params
return carry + 1, (result.x, -result.fun, result.success)
_, v_values = jax.lax.scan(update_v, 0, model.grid)
return v_values
```
This raises the following error while calling `T_jax`
```
[/usr/local/lib/python3.8/dist-packages/jaxopt/_src/scipy_wrappers.py](https://localhost:8080/#) in jnp_to_onp(x_jnp, dtype)
116 determined by NumPy's casting rules for the concatenate method.
117 """
--> 118 x_onp = [onp.asarray(leaf, dtype).reshape(-1)
119 for leaf in tree_util.tree_leaves(x_jnp)]
120 # NOTE(fllinares): return value must *not* be read-only, I believe.
[/usr/local/lib/python3.8/dist-packages/jaxopt/_src/scipy_wrappers.py](https://localhost:8080/#) in (.0)
116 determined by NumPy's casting rules for the concatenate method.
117 """
--> 118 x_onp = [onp.asarray(leaf, dtype).reshape(-1)
119 for leaf in tree_util.tree_leaves(x_jnp)]
120 # NOTE(fllinares): return value must *not* be read-only, I believe.
TracerArrayConversionError: The numpy.ndarray conversion method __array__() was called on the JAX Tracer object Tracedwith
```
Contributor guide
Assessment
This issue has not been assessed yet.