-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Description
Description
It is very handy to use the quantity_input
decorator to ensure the inputs to a function are Quantities with appropriate units. But this checking makes it impossible to use the function with the python package uncertainties
or other automatic-differentiation tools that rely on passing things that behave enough like numbers to pass through simple mathematics. In an ideal world one would be able to attach units to such exotic objects, but in practical terms the easiest thing to do is to pass these objects through the raw un-decorated version of the function - if the decorator provided that.
Additional context
I suggest usage that looks like:
@quantity_input
def f(x: u.m):
return x**2
f(1*u.m)
f.raw(ufloat(1, 0.1))
This should be implementable, if desired, just by storing the function to be wrapped in an attribute of the wrapper object.