-
Notifications
You must be signed in to change notification settings - Fork 478
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
NumPy Computation Efficiency #326
Comments
Thanks for your comments. As far as I know people have used three "solutions" for this:
It would be great to tackle this. To my knowledge nobody is trying as the source of the problem is the NumPy's API. Maybe the recent changes in NumPy allow us to do this. I would be happy to help you and discuss with you if you want to work on it!. Regarding the other questions we tried in two directions. See the _ndarray branch for part of the work and this issue in numpy (numpy/numpy#4072) for a different one. |
OK. Here is a first attempt at trying to make this happen: lkilcher@b4e2b4b Note that according to the docs, I ran the unit tests, and this passes all but 5 of them. Two of those failures are due to the non-standard version number of the current numpy-dev branch. The other three come-up in a Also, at this point I've mostly just copied code from your Anyway, let me know what you think. |
Sorry for the delay. Nice work!. I would be very interested in some benchmarks. Can you try your branch with and without your new code (both with the same version of Python and Numpy)? Just be sure that pint is not installed (so you get your working version), move to the root pint folder (the one containing setup.py) and run in linux/osx PYTHONPATH=. python bench/bench.py If you are working on windows just copy bench.py from inside the bench folder and run python bench.py (I think I will put bench in the root just to make it easier to explain!) |
Regarding your questions:
|
OK. I've run the bench tests. I assume you're only interested in the Using NumPy 10.4 (pre pint master + NumPy 10.4
When I switch to NumPy-dev, the results change dramatically for both pint master and lkilcher/dev: pint master + NumPy dev
lkilcher/dev + NumPy dev
What's interesting here is that pint master + NumPy dev is an order of magnitude slower than pint master + NumPy 10.4. Perhaps this is a result of my NumPy 10.4 having been optimized in some way? In that case, why is the Anyway, on the plus side, the lkilcher/dev + NumPy dev results are an order of magnitude faster than pint master + NumPy dev, and about 20% faster than pint master + NumPy 10.4. I haven't figured out the |
The only explanation that I have is that NumPy dev has actually broken (slowed down) In any case, as you mentioned, your patch is definitely a good thing. I would suggest to clean up the handling part, try to fix the |
OK, I've boiled this down as much as I know how. I'm beginning to think this is an upstream bug where |
I think your gist shows it quite clearly. Unless we are missing something obvious, I think it would be good to have some feedback from the NumPy Devs using your gist. |
OK. Let's see what they say. |
Well, it looks like this is all for not. Unfortunately Should we stash these changes in a branch of your repo so that I don't accidentally delete them? |
I will definitely pull your changes into a new branch. I am sure we will use them. The current |
It seems that there might be a new way to deal with this: |
The last paragraph of the NumPy support doc page, states:
I'm curious if anyone is thinking about resolving the 'calculation is actually done twice' issue using some of the recent changes to the NumPy subclassing structure. In particular it seems like either
__array_prepare__
, or the forthcoming__numpy_ufunc__
could be used to modify input arrays before NumPy computes values in the ufunc call. I knowQuantity
is not technically anumpy.ndarray
subclass, but since you're using the__array_wrap__
functionality, I thought this might be something that could work.I'd be happy to work on this unless you see a reason that it won't work.
I'm also interested in why pint doesn't have a
Quantity
-like subclass ofnumpy.ndarray
, but that's not as critical to me at this point as this performance issue.The text was updated successfully, but these errors were encountered: