[NumPy-Tickets] [NumPy] #1594: numpy.dtype('float64') == None returns True
NumPy Trac
numpy-tickets@scipy....
Thu Aug 26 11:05:22 CDT 2010
#1594: numpy.dtype('float64') == None returns True
-------------------------------+--------------------------------------------
Reporter: Zbyszek_Szmek | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: Unscheduled
Component: Other | Version: devel
Keywords: dtype, comparison |
-------------------------------+--------------------------------------------
Changes (by Zbyszek_Szmek):
* milestone: 2.0.0 => Unscheduled
Comment:
From numpy-discussion...
On Wed, Aug 25, 2010 at 12:41:37PM -0500, Travis Oliphant wrote:
>
> On Aug 23, 2010, at 11:55 AM, Zbyszek Szmek wrote:
>
> > On Mon, Aug 23, 2010 at 06:50:09PM +0200, Tiziano Zito wrote:
> >> hi all,
> >> we just noticed the following weird thing:
> >>
> >> $ python
> >> Python 2.6.6rc2 (r266rc2:84114, Aug 18 2010, 07:33:44)
> >> [GCC 4.4.5 20100816 (prerelease)] on linux2
> >> Type "help", "copyright", "credits" or "license" for more
information.
> >>>>> import numpy
> >>>>> numpy.version.version
> >> '2.0.0.dev8469'
> > Also with numpy.version.version == 1.3.0.
>
> This certainly looks odd. If you can file a bug-report that would be
great.
arraydescr_richcompare calls PyArray_DescrConverter, which converts None
to PyArray_DEFAULT...
/*NUMPY_API
* Get typenum from an object -- None goes to PyArray_DEFAULT
* This function takes a Python object representing a type and converts it
* to a the correct PyArray_Descr * structure to describe the type.
*
* Many objects can be used to represent a data-type which in NumPy is
* quite a flexible concept.
*
* This is the central code that converts Python objects to
* Type-descriptor objects that are used throughout numpy.
* new reference in *at
*/
NPY_NO_EXPORT int
PyArray_DescrConverter(PyObject *obj, PyArray_Descr **at)
So:
>>> numpy.dtype('float32') == '<f4'
True
>>> numpy.dtype('float32') == 'float64'
False
>>> numpy.dtype('float32') == 'float32'
True
>>> numpy.dtype('float32') == 'float33'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: data type not understood
I think that this automatic conversion is pretty dangerous, especially in
case
of None.
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1594#comment:1>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list