[Numpy-discussion] Automatic custom dtype

Richard Hattersley rhattersley at gmail.com
Fri Jun 21 09:09:53 EDT 2013


Hi all,

In my continuing adventures in the Land of Custom Dtypes I've come
across some rather disappointing behaviour in 1.7 & 1.8.

I've defined my own class `Time360`, and a corresponding dtype
`time360` which references Time360 as its scalar type.

Now with 1.6.2 I can do:
>>> t = Time360(2013, 6, 29)
>>> np.array([t]).dtype
dtype('Time360')

And since all the instances supplied to the function were instances of
the scalar type for my dtype, numpy automatically created an array
using my dtype. Happy days!

But in 1.7 and 1.8 I get:
>>> np.array([t]).dtype
dtype('O')

So now I just get a plain old object array. Boo! Hiss!

Is this expected? Desirable? An unwanted regression?

Richard



More information about the NumPy-Discussion mailing list