From: Eric E. <ems...@ob...> - 2006-06-15 13:37:25
|
Hi, I have written a number of small modules where I now systematically use numpy. I have in principle used the latest versions of the different array/Science modules (scipy, numpy, ..) but still at some point during a selection, it crashes on numpy because it seems that the array correspond to "numarray" arrays. e.g.: ################################## selection = (rell >= 1.) * (rell < ES0.maxEFFR[indgal]) ################################## ### rell is an array of reals and ES0.maxEFFR[indgal] is a real number. gives the error: ========== /usr/local/lib/python2.4/site-packages/numarray/numarraycore.py:376: UserWarning: __array__ returned non-NumArray instance _warnings.warn("__array__ returned non-NumArray instance") /usr/local/lib/python2.4/site-packages/numarray/ufunc.py in _cache_miss2(self, n1, n2, out) 919 (in1, in2), inform, scalar = _inputcheck(n1, n2) 920 --> 921 mode, win1, win2, wout, cfunc, ufargs = \ 922 self._setup(in1, in2, inform, out) 923 /usr/local/lib/python2.4/site-packages/numarray/ufunc.py in _setup(self, in1, in2, inform, out) 965 if out is None: wout = in2.new(outtypes[0]) 966 if inform == "vv": --> 967 intypes = (in1._type, in2._type) 968 inarr1, inarr2 = in1._dualbroadcast(in2) 969 fform, convtypes, outtypes, cfunc = self._typematch_N(intypes, inform) AttributeError: 'numpy.ndarray' object has no attribute '_type' ================================================ QUESTION 1: Any hint on where numarray could still be appearing? QUESTION 2: how would you make a selection using "and" and "or" such as: selection = (condition 1) "and" (condition2 "or" condition3) so that "selection" contains 0 and 1 according to the right hand side. Thanks, Eric P.S.: my config is: matplotlib version 0.87.3 verbose.level helpful interactive is False platform is linux2 numerix numpy 0.9.9.2624 font search path ['/usr/local/lib/python2.4/site-packages/matplotlib/mpl-data'] backend GTKAgg version 2.8.2 Python 2.4.2 (#1, May 2 2006, 08:13:46) IPython 0.7.2 -- An enhanced Interactive Python. I am using numerix = numpy in matplotlibrc. I am also using NUMERIX = numpy when building pyfits. -- ==================================================================== Eric Emsellem ems...@ob... Centre de Recherche Astrophysique de Lyon 9 av. Charles-Andre tel: +33 (0)4 78 86 83 84 69561 Saint-Genis Laval Cedex fax: +33 (0)4 78 86 83 86 France http://www-obs.univ-lyon1.fr/eric.emsellem ==================================================================== |
From: Fernando P. <fpe...@gm...> - 2006-06-15 17:25:13
|
On 6/15/06, Eric Emsellem <ems...@ob...> wrote: > Hi, > > I have written a number of small modules where I now systematically use > numpy. > > I have in principle used the latest versions of the different > array/Science modules (scipy, numpy, ..) but still at some point during > a selection, it crashes on numpy because it seems that the array > correspond to "numarray" arrays. [...] > QUESTION 1: Any hint on where numarray could still be appearing? Not a final answer, but I've had the same thing happen to me recently (I'm making the transition right now) with extension modules which were built against Numeric (in my case). They return old Numeric arrays (I had 23.7, without the array interface) and numpy is not happy. Rebuilding all my extensions against numpy fixed the problem. Cheers, f |
From: bryce h. <bhe...@en...> - 2006-06-15 17:41:41
|
We've had the same problem many times. There were a few causes: * Our clean scripts don't delete c++ files, so generated code was often not re-generated when we switched to numpy * Files to generate code had numeric arrays hardcoded * we were using numerix, and the env var was not set for part of the build How I generally detect the problem is by deleting the numeric/numarray package directories, then running python with the verbose flag. Bryce Fernando Perez wrote: > On 6/15/06, Eric Emsellem <ems...@ob...> wrote: > >> Hi, >> >> I have written a number of small modules where I now systematically use >> numpy. >> >> I have in principle used the latest versions of the different >> array/Science modules (scipy, numpy, ..) but still at some point during >> a selection, it crashes on numpy because it seems that the array >> correspond to "numarray" arrays. >> > > [...] > > >> QUESTION 1: Any hint on where numarray could still be appearing? >> > > Not a final answer, but I've had the same thing happen to me recently > (I'm making the transition right now) with extension modules which > were built against Numeric (in my case). They return old Numeric > arrays (I had 23.7, without the array interface) and numpy is not > happy. > > Rebuilding all my extensions against numpy fixed the problem. > > Cheers, > > f > > > _______________________________________________ > Numpy-discussion mailing list > Num...@li... > https://lists.sourceforge.net/lists/listinfo/numpy-discussion > > |
From: <hu...@ya...> - 2006-06-15 21:06:21
|
Just a guess, you're reading some fits file with pyfits but you didn't decl= are=20 the variable NUMERIX for numpy (with the beta version of pyfits) or you=20 script are calling another script who are using numarray. I had both proble= m=20 last week. Pyfits with a mix of numarray/numpy and a script to read some da= ta=20 and return it like an array. N. Le jeudi 15 juin 2006 06:35, Eric Emsellem a =E9crit=A0: > Hi, > > I have written a number of small modules where I now systematically use > numpy. > > I have in principle used the latest versions of the different > array/Science modules (scipy, numpy, ..) but still at some point during > a selection, it crashes on numpy because it seems that the array > correspond to "numarray" arrays. > > e.g.: > ################################## > selection =3D (rell >=3D 1.) * (rell < ES0.maxEFFR[indgal]) > ################################## > ### rell is an array of reals and ES0.maxEFFR[indgal] is a real number. > > gives the error: > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > /usr/local/lib/python2.4/site-packages/numarray/numarraycore.py:376: > UserWarning: __array__ returned non-NumArray instance > _warnings.warn("__array__ returned non-NumArray instance") > /usr/local/lib/python2.4/site-packages/numarray/ufunc.py in > _cache_miss2(self, n1, n2, out) > 919 (in1, in2), inform, scalar =3D _inputcheck(n1, n2) > 920 > --> 921 mode, win1, win2, wout, cfunc, ufargs =3D \ > 922 self._setup(in1, in2, inform, out) > 923 > > /usr/local/lib/python2.4/site-packages/numarray/ufunc.py in _setup(self, > in1, in2, inform, out) > 965 if out is None: wout =3D in2.new(outtypes[0]) > 966 if inform =3D=3D "vv": > --> 967 intypes =3D (in1._type, in2._type) > 968 inarr1, inarr2 =3D in1._dualbroadcast(in2) > 969 fform, convtypes, outtypes, cfunc =3D > self._typematch_N(intypes, inform) > > AttributeError: 'numpy.ndarray' object has no attribute '_type' > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > QUESTION 1: Any hint on where numarray could still be appearing? > > QUESTION 2: how would you make a selection using "and" and "or" such as: > selection =3D (condition 1) "and" (condition2 "or" > condition3) so that "selection" contains 0 and 1 according to the right > hand side. > > Thanks, > > Eric > P.S.: > my config is: > > matplotlib version 0.87.3 > verbose.level helpful > interactive is False > platform is linux2 > numerix numpy 0.9.9.2624 > font search path > ['/usr/local/lib/python2.4/site-packages/matplotlib/mpl-data'] > backend GTKAgg version 2.8.2 > Python 2.4.2 (#1, May 2 2006, 08:13:46) > IPython 0.7.2 -- An enhanced Interactive Python. > > I am using numerix =3D numpy in matplotlibrc. I am also using NUMERIX =3D > numpy when building pyfits. |