-
-
Notifications
You must be signed in to change notification settings - Fork 78
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 Deprecation warning #114
Comments
please add the exact version information for numpy and uncertainties to your initial ticket (edit). |
Thanks for reporting this. Handling this requires some care: users expect I'm thinking that uncertainties should deprecate Another thing that should be done is to see how to replace the |
So we could deprecate unumpy.matrix with warnings. I think inversion can bé done with numpy linalg module https://numpy.org/devdocs/reference/generated/numpy.linalg.inv.html#numpy.linalg.inv |
Yes, indeed.
|
Hello, I found the same warning. My context is different. I have been using umatrices for a dot product. I have not found any linalg function or unumpy function to do a dot product with the uarray objects. Is there a built in function to do dot products with the uarray objects? If not, maybe a volunteer should offer to help build this in for when umatrix becomes deprecated. This is beyond my python knowledge, but it looks like it may not be too hard for a volunteer that knows how to do it. We see that the uncertainties core has this in the matrix class:
Since it is relying upon numeric.dot from the numpy core, it seems like somebody who knows how could create unumpy.dot (or unumpy.uarray.dot) to mimic the numpy function https://docs.scipy.org/doc/numpy/reference/generated/numpy.dot.html |
Have you tried using numpy.dot() or the @ operator as usual? There is no "uarray" class: the uarray() factory returns a regular NumPy array, which should behave as expected (in many contexts). |
I'm sorry for my delay in responding, I needed to wait until I got home from work due to which computer the code is on. I had tried syntax like "unumpy.dot()" since I did not realize we could use the numpy functions directly. You are right (of course you are!) that using the @ operator with uarrays does work. It might be good to provide an @ operator example in the documentation (or to mention it). Also to provide some example explaining that 'arbitrary' directly numpy functions are likely to work with uarrays. I looked again and didn't easily find examples of that in the documentation, I see mostly examples using unumpy functions. I feel guilty suggesting more work for you, but it would be helpful for some users to see such examples. |
That's a fair point, about giving more examples of arrays with numbers with uncertainties behaving as expected with the standard NumPy functions. The documentation states early that "basic operations on arrays that contain numbers with uncertainties can be performed without [the unumpy package]", but this is only in passing, so it's a good idea to illustrate this point. To do:
|
@lebigot I was getting a warning from numpy during pytest that the numpy matrix class is going to become deprecated because as of python 3.5 the numpy arrays can do all of the same things as the matrix class. anaconda3\envs\uncertainties\lib\site-packages\numpy\matrixlib\defmatrix.py:69: PendingDeprecationWarning: the matrix subclass is not the recommended way to represent matrices or deal with linear algebra (see https://docs.scipy.org/doc/numpy/user/numpy-for-matlab-users.html). Please adjust your code to use regular ndarray. The numpy warning says to look at this link: https://numpy.org/doc/stable/user/numpy-for-matlab-users.html which says to always use arrays and that matrix will become deprecated. Well, I suppose the warning is not the only reason to fix this... since matrix will eventually become deprecated. Based on my history with numpy... I'd speculate that will happen in the next 1-2 years This may also be related to: #120 |
This PR has been stale for some time, but I can't find an answer and I need help with the same issue. I try to invert an array with uncertainties
All of this being said, what is the correct and deprecation-safe way to invert the array? @lebigot suggested 5 years ago:
But if this refers to I am using python 3.10, numpy 1.23.4, and uncertainties 3.1.7. |
uncertainties.unumpy.array
throwsDeprecationWarnings
from bothnumpy 1.16.5
in python 2 andnumpy 1.17.4
in python 3:The text was updated successfully, but these errors were encountered: