[Numpy-discussion] Is this a bug?
Robert Kern
robert.kern at gmail.com
Tue May 27 17:07:54 EDT 2008
On Tue, May 27, 2008 at 3:15 PM, Travis E. Oliphant
<oliphant at enthought.com> wrote:
> Charles R Harris wrote:
>>
>> On Tue, May 27, 2008 at 1:31 PM, Travis E. Oliphant
>> <oliphant at enthought.com <mailto:oliphant at enthought.com>> wrote:
>>
>> Charles R Harris wrote:
>> > I vaguely recall this generated an array from all the characters.
>> >
>> > In [1]: array('123', dtype='c')
>> > Out[1]:
>> > array('1',
>> > dtype='|S1')
>> This may be a bug.
>>
>> >>> import Numeric
>> >>> Numeric.array('123','c')
>> array([1, 2, 3],'c')
>>
>> My memory of the point of 'c' was to mimic Numeric's behavior for
>> character arrays.
>>
>>
>> Current behavior after fix is
>>
>> In [1]: array('123','c')
>> Out[1]:
>> array(['1', '2', '3'],
>> dtype='|S1')
>>
>> Is that correct, then?
> Yes.
Can we make it so that dtype('c') is preserved instead of displaying
'|S1'? It does not behave the same as dtype('|S1') although it
compares equal to it.
In [90]: dtype('c')
Out[90]: dtype('|S1')
In [91]: array('123', dtype='c')
Out[91]:
array(['1', '2', '3'],
dtype='|S1')
In [92]: array('123', dtype=dtype('c'))
Out[92]:
array(['1', '2', '3'],
dtype='|S1')
In [93]: array('123', dtype=dtype('|S1'))
Out[93]:
array('1',
dtype='|S1')
In [94]: array('456', dtype=array('123', dtype=dtype('c')).dtype)
Out[94]:
array(['4', '5', '6'],
dtype='|S1')
In [95]: dtype('c') == dtype('|S1')
Out[95]: True
--
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