[Numpy-discussion] Is this a bug?

Robert Kern robert.kern@gmail....
Wed May 28 20:18:11 CDT 2008


On Wed, May 28, 2008 at 7:52 PM, Travis E. Oliphant
<oliphant@enthought.com> wrote:
> Anne Archibald wrote:
>> 2008/5/27 Robert Kern <robert.kern@gmail.com>:
>>
>>> 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.
>>>
>>
>> It seems alarming to me that they should compare equal but behave
>> differently. Is it possible to change more than just the way it
>> prints?
>>
> comparison on dtype objects is about memory layout equivalency.
> Characters and length-1 strings are equivalent from a memory-layout
> perspective.

That would be fine if dtypes only represented memory layout. However,
in this case, they also represent a difference in interpretation of
str objects in the array() constructor. That is a real difference that
needs to be reflected in __eq__ and __repr__.

-- 
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