Skip to content
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

Add support for median, average, and others #396

Closed
gerritholl opened this issue Jul 6, 2016 · 2 comments · Fixed by #905
Closed

Add support for median, average, and others #396

gerritholl opened this issue Jul 6, 2016 · 2 comments · Fixed by #905

Comments

@gerritholl
Copy link
Contributor

gerritholl commented Jul 6, 2016

I've been trying to add support for more ufuncs that keep units, by adding items to __copy_units. Unfortunately, many ufuncs start with calling asarray or asanyarray, and we probably don't want to mess with those: people calling asarray will not expect to get a Quantity in return. Is there another way this could be achieved?

Relevant ufuncs include: median, average, percentile, expand_dims, atleast_1d, atleast_2d, atleast_3d, tile, rot90, and others.

gerritholl added a commit to gerritholl/pint that referenced this issue Jul 6, 2016
Make a numpy array quantity retain its unit when swapaxes is called.
Previously it would turn into a regular ndarray.  Add a test suite to test
unit retainment for this and other ufuncs in __copy_units.

I also tried to add functionality for others, such as median, average,
percentile, expand_dims, atleast_1d, atleast_2d, atleast_3d, tile, rot90.
However, this doesn't work because those ndarrays start with `asarray` or
`asndarray`.  Onother solution is needed.  See also issue hgrecco#396.
@hgrecco
Copy link
Owner

hgrecco commented Jul 20, 2016

I tried this in the past. The problem is that numpy calls asanyarray which does not accept anything that is not a subclass of ndarray.

@hgrecco
Copy link
Owner

hgrecco commented Dec 3, 2019

Revisit after #905

@hgrecco hgrecco closed this as completed Dec 3, 2019
@hgrecco hgrecco reopened this Dec 3, 2019
@bors bors bot closed this as completed in 43fbae2 Dec 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants