-
Notifications
You must be signed in to change notification settings - Fork 48
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
implementation question: possible to subclass the unyt array type? #39
Comments
It looks like your subclass just attaches metadata to the array, I think it should work without too much hassle. I'd do this by overriding For inspiration you can look at https:/yt-project/unyt/blob/master/unyt/tests/test_unyt_array.py#L1179 If you run into issues please let us know. |
Thanks Nathan. |
We currently have a data type
ArrayIndexer
that is built from subclassingnp.ndarray
:https:/zingale/pyro2/blob/master/mesh/array_indexer.py
We do this to add methods that we wanted for basic finite-difference operations and boundary conditions for our code.
Is there an easy way to subclass
unyt_array
just like one would fornp.ndarray
? We'd like to be able to add units to our type.It maybe that what we are doing is not the best approach anyway, so if there is better way to add methods to the
unyt_array
, we're happy to hear that as well.The text was updated successfully, but these errors were encountered: