[Numpy-discussion] Is this a bug?

Travis E. Oliphant oliphant@enthought....
Fri May 30 21:24:08 CDT 2008


Robert Kern wrote:
> 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__.
>   
I think __repr__ can be changed without trouble.  I'm concerned about 
changing __eq__, however.

-Travis




More information about the Numpy-discussion mailing list