Closed TomClarkMassSpec closed 10 months ago
The best way to do this will be to call as sol = optx.root_find(..., throw=False)
, and then check whether sol.result == optx.RESULTS.successful
.
Based on your example, what you probably want is
Thv = jnp.where(sol.result == optx.RESULTS.successful, sol.value, 999.)
The reason for taking this approach is that a try/except won't work with JITing, so it's almost never what you really want.
Hi,
I'm using a couple Equinox pytrees in my program and in one case it is used in conjunction with Newton root finding from Optimistix. My larger code is a gradient descent variation and occasionally a data point will be expected to not have a solution to the root finding algorithm. In trying to set up try: except: , what is the correct name of the exception class that Equinox uses for runtime errors, or should it be something from optimistix?
Please and thanks, Tom