From: Daran L. R. <dr...@uc...> - 2006-08-10 13:33:56
|
Hello, I am a veteran user of Numeric and am trying out the latest version of numpy (numpy 1.01b) on Mac OS X 10.4 Tiger (8.7.0). When trying to invert a matrix with numpy.linalg.inv I get the following error: ----> Traceback (most recent call last): File "./bias_correction.py", line 381, in ? if __name__ == "__main__": main() File "./bias_correction.py", line 373, in main (index_to_stnid, bias_and_innov) = calc_bias_and_innov(cf, stn_info, obs, infile_obs, grids, infile_grids) File "./bias_correction.py", line 297, in calc_bias_and_innov K = make_kalman_gain(R, P_local, H) File "./bias_correction.py", line 157, in make_kalman_gain K = MA.dot( MA.dot(P, MA.transpose(H)), inv(MA.dot(H, MA.dot(P, MA.transpose(H))) + R ) ) File "/opt/python/lib/python2.4/site-packages/numpy/linalg/linalg.py", line 149, in inv return wrap(solve(a, identity(a.shape[0], dtype=a.dtype))) TypeError: __array_wrap__() takes exactly 3 arguments (2 given) <---- Is this a known problem, and if so, what is the fix? Thanks very much, Daran |
From: David M. C. <co...@ph...> - 2006-08-10 18:22:40
|
On Thu, 10 Aug 2006 07:33:44 -0600 (MDT) "Daran L. Rife" <dr...@uc...> wrote: > Hello, > > I am a veteran user of Numeric and am trying > out the latest version of numpy (numpy 1.01b) > on Mac OS X 10.4 Tiger (8.7.0). > > When trying to invert a matrix with > numpy.linalg.inv I get the following error: > > ----> > > Traceback (most recent call last): > File "./bias_correction.py", line 381, in ? > if __name__ == "__main__": main() > File "./bias_correction.py", line 373, in main > (index_to_stnid, bias_and_innov) = calc_bias_and_innov(cf, stn_info, > obs, infile_obs, grids, infile_grids) > File "./bias_correction.py", line 297, in calc_bias_and_innov > K = make_kalman_gain(R, P_local, H) > File "./bias_correction.py", line 157, in make_kalman_gain > K = MA.dot( MA.dot(P, MA.transpose(H)), inv(MA.dot(H, MA.dot(P, > MA.transpose(H))) + R ) ) > File "/opt/python/lib/python2.4/site-packages/numpy/linalg/linalg.py", > line 149, in inv > return wrap(solve(a, identity(a.shape[0], dtype=a.dtype))) > TypeError: __array_wrap__() takes exactly 3 arguments (2 given) > > <---- > > Is this a known problem, and if so, what is the fix? It looks like the problem is that numpy.core.ma.MaskedArray.__array_map__ expects a "context" argument, but none gets passed. I'm not familiar with that, so I don't know what the fix is ... -- |>|\/|< /--------------------------------------------------------------------------\ |David M. Cooke http://arbutus.physics.mcmaster.ca/dmc/ |co...@ph... |
From: Sasha <nd...@ma...> - 2006-08-10 18:41:36
|
Inverting a matrix with masked values does not make much sense. Call "filled" method with an appropriate fill value before passing the matrix to "inv". On 8/10/06, Daran L. Rife <dr...@uc...> wrote: > Hello, > > I am a veteran user of Numeric and am trying > out the latest version of numpy (numpy 1.01b) > on Mac OS X 10.4 Tiger (8.7.0). > > When trying to invert a matrix with > numpy.linalg.inv I get the following error: > > ----> > > Traceback (most recent call last): > File "./bias_correction.py", line 381, in ? > if __name__ == "__main__": main() > File "./bias_correction.py", line 373, in main > (index_to_stnid, bias_and_innov) = calc_bias_and_innov(cf, stn_info, > obs, infile_obs, grids, infile_grids) > File "./bias_correction.py", line 297, in calc_bias_and_innov > K = make_kalman_gain(R, P_local, H) > File "./bias_correction.py", line 157, in make_kalman_gain > K = MA.dot( MA.dot(P, MA.transpose(H)), inv(MA.dot(H, MA.dot(P, > MA.transpose(H))) + R ) ) > File "/opt/python/lib/python2.4/site-packages/numpy/linalg/linalg.py", > line 149, in inv > return wrap(solve(a, identity(a.shape[0], dtype=a.dtype))) > TypeError: __array_wrap__() takes exactly 3 arguments (2 given) > > <---- > > Is this a known problem, and if so, what is the fix? > > > Thanks very much, > > > Daran > > > > > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Numpy-discussion mailing list > Num...@li... > https://lists.sourceforge.net/lists/listinfo/numpy-discussion > |
From: Daran L. R. <dr...@uc...> - 2006-08-10 19:33:59
|
Hi Sasha, > Inverting a matrix with masked values does not make much sense. Call > "filled" method with an appropriate fill value before passing the > matrix to "inv". In principle you are right, but even though I use masked arrays in this operation, when the operation itself is done no masked values remain. Thus, my code works very well with the "old" Numeric--and has worked well for some time. That said, I will try your suggestion of doing a "filled" on the matrix before sending it off to the inverse module. Thanks, Daran |
From: Sasha <nd...@ma...> - 2006-08-10 20:07:19
|
I see that Travis just fixed that by making context optional <http://projects.scipy.org/scipy/numpy/changeset/2987>. I am not sure it is a good idea to allow use of ufuncs for which domain is not defined in ma. This may lead to hard to find bugs coming from ma arrays with nans in the data. I would rather see linalg passing the (func,args) context to wrap. That would not fix the reported problem, but will make diagnostic clearer. On 8/10/06, Daran L. Rife <dr...@uc...> wrote: > Hi Sasha, > > > Inverting a matrix with masked values does not make much sense. Call > > "filled" method with an appropriate fill value before passing the > > matrix to "inv". > > In principle you are right, but even though I use masked arrays > in this operation, when the operation itself is done no masked > values remain. Thus, my code works very well with the "old" > Numeric--and has worked well for some time. That said, I will > try your suggestion of doing a "filled" on the matrix before > sending it off to the inverse module. > > > Thanks, > > > Daran > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Numpy-discussion mailing list > Num...@li... > https://lists.sourceforge.net/lists/listinfo/numpy-discussion > |
From: Travis O. <oli...@ie...> - 2006-08-10 20:22:26
|
Sasha wrote: > I see that Travis just fixed that by making context optional > <http://projects.scipy.org/scipy/numpy/changeset/2987>. I am not sure > it is a good idea to allow use of ufuncs for which domain is not > defined in ma. This may lead to hard to find bugs coming from ma > arrays with nans in the data. I would rather see linalg passing the > (func,args) context to wrap. That would not fix the reported problem, > but will make diagnostic clearer. > > This can be done as well. The problem is that __array_wrap__ is used in quite a few places (without context) and ma needs to have a default behavior when context is not supplied. -Travis |