Skip to content

Potential issues in scico.solver #486

@bwohlberg

Description

@bwohlberg

The comment on this line in scico.solver.minimize

x0 = x0.ravel() # if x0 is a BlockArray it will become a jax array here

is incorrect. This should be edited, and it should be confirmed that the functions does work for BlockArray input.

It's not clear whether the use of nonlocal and the "with side effects" is really necessary

scico/scico/solver.py

Lines 233 to 250 in 4eb21c1

def fun(x0):
nonlocal res # To use the external res and update side effect
res = spopt.minimize(
min_func,
x0=x0,
args=args,
jac=jac,
method=method,
options=options,
) # Returns OptimizeResult with x0 as ndarray
return res.x.astype(x0_dtype)
# HCB call with side effects to get the OptimizeResult on the same device it was called
res.x = hcb.call(
fun,
arg=x0,
result_shape=x0, # From Jax-docs: This can be an object that has .shape and .dtype attributes
)

It would be worth confirming this or simplifying the code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdiscussion requiredSome discussion necessary to decide how to address this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions