[Numpy-discussion] A bug in repeat function?
Todd Miller
jmiller at stsci.edu
Wed Feb 11 10:07:17 EST 2004
On Tue, 2004-02-10 at 03:21, Nadav Horesh wrote:
> 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.
This turned out to be a problem with summing the bool array to get an
element count for the result array from the repeat. This is fixed now
in CVS.
Regards,
Todd
>
--
Todd Miller <jmiller at stsci.edu>
More information about the NumPy-Discussion
mailing list