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
For performance and compatibility reasons, I need to write a function that accepts and returns floats, but I want to provide a "unitized" version of the function using @wraps or @check. I've run into some limitations, and I want to make sure I fully understand the intended use of these two decorators.
wraps and check are not intendend to be combined. The first is intended to convert a standard function into a unit aware function. The wrapper convert the input into magnitudes of the chosen units which in turn are supplied to the wrapped function. The second only checks that the units or dimensions are right. So wraps converts (implicit check) and magnitud extraction.
I would like to support that case.
The right way would be to make wraps accept dimensions and fix the default value.
For performance and compatibility reasons, I need to write a function that accepts and returns floats, but I want to provide a "unitized" version of the function using @wraps or @check. I've run into some limitations, and I want to make sure I fully understand the intended use of these two decorators.
Suppose my function is
For the unitized version, I want to enforce that
I can accomplish 1) with @check
and 2) and 3) with @wraps
But, @wraps only works properly when b is passed explicitly. If the default value is used, it raises a
ValueError
(see #439).ValueError: A wrapped function using strict=True requires quantity or a string for all arguments with not None units.
So, my questions are:
wraps
andcheck
functions be combined / chained to accomplish both dimensionality and units checking?Thank you!
The text was updated successfully, but these errors were encountered: