You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have the possibility of a speed upgrade by changing "if then raise" statements to assert cases in the backend.
In cases were we know that a model is safe to run, we could call the -O option for python to skip these cases automatically.
We have these in several loops in the backend, so it could net a performance bump.
Version
v0.7
The text was updated successfully, but these errors were encountered:
Here is an example for the expression_parser.py file. The for is entirely for checking.
Although in this case, maybe if __debug__ is better than assert.
defas_array(self) ->xr.DataArray: # noqa: D102, overridelhs, rhs=self._eval("array")
where=self.eval_attrs["where_array"]
forside, arrin {"left": lhs, "right": rhs}.items():
extra_dims=set(arr.dims).difference(set(where.dims))
ifextra_dims:
raiseBackendError(
f"({self.eval_attrs['equation_name']}, {self.instring}) | "f"The {side}-hand side of the equation is indexed over dimensions not present in `foreach`: {extra_dims}"
)
lhs_where=lhs.broadcast_like(where)
rhs_where=rhs.broadcast_like(where)
matchself.op:
case"==":
op=np.equalcase"<=":
op=np.less_equalcase">=":
op=np.greater_equalconstraint=op(lhs_where, rhs_where, where=where.values, dtype=np.object_)
returnxr.DataArray(constraint)
Some hits of viable cases I found. Number on the left indicates "hits" (also national example).
Couldn't find a way to make the debugger add them all together, sadly.
What can be improved?
We have the possibility of a speed upgrade by changing "if then raise" statements to
assert
cases in the backend.In cases were we know that a model is safe to run, we could call the -O option for python to skip these cases automatically.
We have these in several loops in the backend, so it could net a performance bump.
Version
v0.7
The text was updated successfully, but these errors were encountered: