[Numpy-discussion] Is this a bug?

Robert Kern robert.kern@gmail....
Mon May 26 15:13:15 CDT 2008


On Mon, May 26, 2008 at 3:03 PM, Charles R Harris
<charlesr.harris@gmail.com> wrote:
>
> On Mon, May 26, 2008 at 1:52 PM, Charles R Harris
> <charlesr.harris@gmail.com> wrote:
>>
>>
>> On Mon, May 26, 2008 at 1:44 PM, Robert Kern <robert.kern@gmail.com>
>> wrote:
>>>
>>> On Mon, May 26, 2008 at 11:29 AM, Charles R Harris
>>> <charlesr.harris@gmail.com> wrote:
>>> > I vaguely recall this generated an array from all the characters.
>>> >
>>> > In [1]: array('123', dtype='c')
>>> > Out[1]:
>>> > array('1',
>>> >       dtype='|S1')
>>>
>>> When was the last time it did otherwise? This behavior is a
>>> consequence of treating strings as scalars rather than containers of
>>> characters. I believe we settled on this behavior before 1.0.
>>
>> The 'c' type is special, it is a left over compatibility type for numeric.
>> It would, I think, have been several months ago that it behaved differently.
>> Maybe I should check out a version from before Travis's latest fixes for
>> matrix types went in, because there used to be an exception in the code for
>> the 'c' type.
>
> It works the same in r5101, so it looks like it hasn't changed. What I
> vaguely remembered was the whole string being treated as a sequence of
> characters, but evidently that is not the case. Probably I remembered the
> opposite of the case from looking at the code back when.

numpy 1.0 had the behaviour you describe.


>>> import numpy
>>> numpy.__version__
'1.0'
>>> numpy.array('123', dtype='c')
array(['1', '2', '3'],
      dtype='|S1')

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
 -- Umberto Eco


More information about the Numpy-discussion mailing list