Another reason to remove constants. If an attribute is set in _static_attr but passed inside constants and used from there as constants['static'], it throws a TracerConversion error during evaluation. For example,
eq = get("precise_QA")
obj = ObjectiveFunction(QuasisymmetryBoozer(eq=eq, surf_batch_size=1))
obj.build()
obj.compute_scaled_error(obj.x(eq))
TracerBoolConversionError: Attempted boolean conversion of traced array with shape bool[].
The error occurred while tracing the function compute_scaled_error at
/CODES/DESC/desc/objectives/objective_funs.py:1444 for jit. This concrete value was not
available in Python because it depends on the value of the argument
self[0]['_constants']['surf_batch_size'].
I think fixing QuasisymmetryBoozer is enough for this issue, but I still wanted to document this problem in general.
Another reason to remove
constants. If an attribute is set in_static_attrbut passed insideconstantsand used from there asconstants['static'], it throws aTracerConversionerror during evaluation. For example,I think fixing
QuasisymmetryBoozeris enough for this issue, but I still wanted to document this problem in general.