[Numpy-discussion] Behavior from a change in dtype?

Skipper Seabold jsseabold at gmail.com
Mon Sep 7 18:36:13 EDT 2009


Hello all,

I ran into a problem with some of my older code (since figured out the
user error).  However, in trying to give a simple example that
replicates the problem I was having, I ran into this.

In [19]: a = np.array((1.))

In [20]: a
Out[20]: array(1.0)

# the dtype is 'float64'

In [21]: a.dtype='<i8'

In [22]: a
Out[22]: array(4607182418800017408)

I've seen some recent threads about handling changes in types, but I
didn't follow closely, so forgive me if I'm missing something that is
known.  In general, is it just a bad idea to touch the dtype like
this?

Best,
Skipper



More information about the NumPy-Discussion mailing list