[SciPy-dev] chararry array method
oliphant at ee.byu.edu
Thu Dec 29 16:00:55 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.
>I guess I'm trying to understand if the following example will work. In
>numarray, I can say the following:
>In : from numarray import strings as chararray
>In : arr2 = chararray.array('abcdefg'*10,itemsize=10)
>In : arr2
>CharArray(['abcdefgabc', 'defgabcdef', 'gabcdefgab', 'cdefgabcde',
> 'fgabcdefga', 'bcdefgabcd', 'efgabcdefg'])
So, this is taking a buffer and chopping it into string bits.
Currently, the chararray array function does not take a buffer input.
I would suggest not using character arrays in pyfits just yet. They are
not really necessary, because normal arrays can be of string type. If
you really need the functionality of the chararray (string methods or
equality testing), then create it after creating the normal array (no
data will be copied). I'd like to better understand use cases of
special string arrays a little better. I'm not sure I completely
understand why numarray split everything into different array types.
Much more is supported in the basic array type in scipy.
More information about the Scipy-dev