
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. Best, Zbyszek