[Numpy-discussion] Incompatibility betwewn numarray 1.2.2 and Numeric

Nadav Horesh NadavH at VisionSense.com
Thu Feb 24 06:58:01 CST 2005


Numeric and numarray arrays became incopatible ---
Is it a bug or a design change?


In [10]: import Numeric as N

In [11]: A = N.arange(6.0)

In [12]: import numarray as n

In [13]: a = n.arange(6.0)

In [14]: a+A                  # numarray op Numeric
---------------------------------------------------------------------------
exceptions.ValueError                                Traceback (most 
recent call last)

/tmp/numarray-1.2.2/<console>

/usr/local/lib/python2.4/site-packages/numarray/numarraycore.py in 
__add__(self, operand)
    933             return operand.__radd__(self)
    934         else:
--> 935             return ufunc.add(self, operand)
    936    
    937     def __radd__(self, operand):

/usr/local/lib/python2.4/site-packages/numarray/ufunc.py in 
_cache_miss2(self, n1, n2, out)
    918
    919     def _cache_miss2(self, n1, n2, out):
--> 920         (in1, in2), inform, scalar = _inputcheck(n1, n2)
    921        
    922         mode, win1, win2, wout, cfunc, ufargs = \

/usr/local/lib/python2.4/site-packages/numarray/ufunc.py in 
_inputcheck(*inargs)    374             # see if it can be made into an 
array
    375             try:
--> 376                 inarg = _nc.array(inarg)
    377             except TypeError:
    378                 raise TypeError(

/usr/local/lib/python2.4/site-packages/numarray/numarraycore.py in 
array(sequence, typecode, copy, savespace, type, shape)
    399     if shape is None:
    400         shape=()
--> 401     return fromlist([sequence],type,shape)
    402
    403 def asarray(seq, type=None, typecode=None):

/usr/local/lib/python2.4/site-packages/numarray/numarraycore.py in 
fromlist(seq, type, shape, check_overflow, typecode)
    245     tshape = _frontseqshape(seq)
    246     if shape is not None and _gen.product(shape) != 
_gen.product(tshape):
--> 247         raise ValueError("shape incompatible with sequence")
    248     ndim = len(tshape)
    249     if ndim <= 0:

ValueError: shape incompatible with sequence

In [15]: A+a     # The other way around
---------------------------------------------------------------------------
exceptions.ValueError                                Traceback (most 
recent call last)

/tmp/numarray-1.2.2/<console>

/usr/local/lib/python2.4/site-packages/numarray/numarraycore.py in 
__radd__(self, operand)
    940             return operand.__add__(self)
    941         else:
--> 942             r = ufunc.add(operand, self)
    943             if isinstance(r, NumArray):
    944                 r.__class__ = self.__class__

/usr/local/lib/python2.4/site-packages/numarray/ufunc.py in 
_cache_miss2(self, n1, n2, out)
    918
    919     def _cache_miss2(self, n1, n2, out):
--> 920         (in1, in2), inform, scalar = _inputcheck(n1, n2)
    921        
    922         mode, win1, win2, wout, cfunc, ufargs = \

/usr/local/lib/python2.4/site-packages/numarray/ufunc.py in 
_inputcheck(*inargs)    374             # see if it can be made into an 
array
    375             try:
--> 376                 inarg = _nc.array(inarg)
    377             except TypeError:
    378                 raise TypeError(

/usr/local/lib/python2.4/site-packages/numarray/numarraycore.py in 
array(sequence, typecode, copy, savespace, type, shape)
    399     if shape is None:
    400         shape=()
--> 401     return fromlist([sequence],type,shape)
    402
    403 def asarray(seq, type=None, typecode=None):

/usr/local/lib/python2.4/site-packages/numarray/numarraycore.py in 
fromlist(seq, type, shape, check_overflow, typecode)
    245     tshape = _frontseqshape(seq)
    246     if shape is not None and _gen.product(shape) != 
_gen.product(tshape):
--> 247         raise ValueError("shape incompatible with sequence")
    248     ndim = len(tshape)
    249     if ndim <= 0:

ValueError: shape incompatible with sequence


--------------------------

  Nadav.




More information about the Numpy-discussion mailing list