-
Notifications
You must be signed in to change notification settings - Fork 476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to make sure Quantity cannot wrap a user defined object #2063
Comments
yea have a try at adding it to upcast types see #1888 |
That's working! however my |
something like class DataBase():
def __new__(cls):
if not pint.compat.is_upcast_type(cls):
# add class to upcast types here |
nice, I wrote:
and all subclass are upcasted! Maybe it could be nice and clearer to add this in the doc rather than digging into past issues? |
yea please |
Hi there,
I'm developing a data acquisition framework (PyMoDAQ) and data handling. The main objects (let's say
DataBase
holds data as a list of numpy arrays and an attribute being units. So I'm using quite a bit of pint functionalities under the hood, simply adding compatibility for list of ndarrays. By implementing array_ufunc and array_function and using their implementation in pint, I could quickly get it working for many functions. However when I execute:I'm getting a quantity with a magnitude being my DataBase object.
When I'm doing the other way around:
I properly (what I want at least) get the product of the underlying quantities (with units handling).
Here comes the question:
How can I be sure that this is always my DataBase that will have the priority?
I tried the
__array_priority__
attribute (I saw you set it to 17 for your numpy wrapping quantities) but it doesn't work.I also almost understand the idea of upcast_type but i'm actually not sure if this is or not related to my issue...
Thxs
The text was updated successfully, but these errors were encountered: