[Numpy-discussion] take() over CharArrays

Todd Miller jmiller at stsci.edu
Fri Dec 12 06:59:04 CST 2003

I agree that this is a necessary feature...  but making take() work
consistently across the range of array types in numarray requires more
thought (and changes I think) than I can do on the eve of a release.
I logged this as the first bug against numarray-0.8.

However, I got array based indexing to work with minimal changes,  so
all is not lost:

>>> a=strings.fromlist(["this"]*25); a.shape=(5,5); a[ range(2,4) ]
CharArray([['this', 'this', 'this', 'this', 'this'],
           ['this', 'this', 'this', 'this', 'this']])
>>> a[ range(2,4) ] = strings.fromlist(["that"]); a
CharArray([['this', 'this', 'this', 'this', 'this'],
           ['this', 'this', 'this', 'this', 'this'],
           ['that', 'that', 'that', 'that', 'that'],
           ['that', 'that', 'that', 'that', 'that'],
           ['this', 'this', 'this', 'this', 'this']])

works now in CVS and will be part of numarray-0.8.


On Fri, 2003-12-12 at 07:34, Francesc Alted wrote:
> Hi,
> take() doesn't seems to work when applied to numarray CharArrays:
> >>> a=strings.array("a"*400, shape=(2,4), itemsize=3)
> >>> take(a, (1,2))
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "/usr/local/lib/python2.3/site-packages/numarray/ufunc.py", line 1766, 
> in take
>     return array._take((indices,), clipmode=clipmode)
>   File "/usr/local/lib/python2.3/site-packages/numarray/generic.py", line 799, 
> in _take
>     impliedShape, N = _takeShape(self, indices)
>   File "/usr/local/lib/python2.3/site-packages/numarray/generic.py", line 133, 
> in _takeShape
>     if scattered.isbyteswapped() or not scattered.iscontiguous():
> AttributeError: 'CharArray' object has no attribute 'isbyteswapped'
> and, IMO, that functionality would be nice to have.
> Cheers,
> -- 
> Francesc Alted
> -------------------------------------------------------
> This SF.net email is sponsored by: SF.net Giveback Program.
> Does SourceForge.net help you be more productive?  Does it
> help you create better code?  SHARE THE LOVE, and help us help
> YOU!  Click Here: http://sourceforge.net/donate/
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Todd Miller 			
Space Telescope Science Institute
3700 San Martin Drive
Baltimore MD, 21030
(410) 338 - 4576

More information about the Numpy-discussion mailing list