[Numpy-discussion] A bug in repeat function?

Nadav Horesh nadavh at visionsense.com
Tue Feb 10 00:23:01 CST 2004


The repeat appears to accpt only short boolean array as repat counters:

>>> A
array([1, 2, 3])
>>> repeat(A, [1,1,1])
array([1, 2, 3])
>>> U = array([1,1,1], type=Bool)
>>> U
array([1, 1, 1], type=Bool)
>>> repeat(A,U)    # OK
array([1, 2, 3])
>>> A = arange(100000)
>>> U = ones(100000, type=Bool)
>>> AA = repeat(A,U)   # U is too long --- an error is generated

Traceback (most recent call last):
  File "<pyshell#90>", line 1, in -toplevel-
    AA = repeat(A,U)
  File "/usr/local/lib/python2.3/site-packages/numarray/generic.py", line 1066, in repeat
    return _repeat(_nc.array(array), repeats)
  File "/usr/local/lib/python2.3/site-packages/numarray/generic.py", line 1054, in _repeat
    newarray = array.__class__(shape=newshape, type=array._type)
ValueError: new_memory: invalid region size: -384.
>>> U = ones(100000)   # It is OK if U type is an integer
>>> AA = repeat(A,U)
>>> 

  Nadav.




More information about the Numpy-discussion mailing list