[SciPy-dev] chararry array method

Travis Oliphant oliphant at ee.byu.edu
Thu Dec 29 16:33:11 CST 2005


Christopher Hanley wrote:

>Travis Oliphant wrote:
>  
>
>>I'm not sure.  Presumably it would pick up its shape from the input object.
>>
>>At some point, I think I'd like to move the chararray into C and have it 
>>be the default return object whenever a string or unicode base-type 
>>array is requested.
>>
>>You can already have arrays of strings without the chararray, except 
>>comparisons don't work.  There are lots of ways to solve that problem, 
>>and I'm not sure the chararray is the best way.  But, it's functional.
>>
>>-Travis
>>
>>    
>>
>
>I guess I'm trying to understand if the following example will work.  In 
>numarray, I can say the following:
>
>
>In [24]: from numarray import strings as chararray
>
>In [25]: arr2 = chararray.array('abcdefg'*10,itemsize=10)
>
>In [26]: arr2
>Out[26]:
>CharArray(['abcdefgabc', 'defgabcdef', 'gabcdefgab', 'cdefgabcde',
>            'fgabcdefga', 'bcdefgabcd', 'efgabcdefg'])
>
>However, when attempting to do something similar with scipy.base I 
>receive the following:
>
>In [27]: arr = sb.chararray.array('abcdefg'*10,itemlen=10)
>  
>

O.K. try it now.  I've updated chararray.array to accept a string input 
and split it like this. 

But... Change itemlen to itemsize.  I fixed this for consistency.

-Travis





More information about the Scipy-dev mailing list