[Numpy-discussion] problem with numpy.. sometimes using numarray? and selection question

Eric Emsellem emsellem at obs.univ-lyon1.fr
Thu Jun 15 08:35:20 CDT 2006


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                             emsellem at obs.univ-lyon1.fr
                           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
====================================================================





More information about the Numpy-discussion mailing list