[Numpy-discussion] subtypes of ndarray and round()

Matti Picus matti.picus at gmail.com
Thu Jul 4 15:43:20 EDT 2013


round() does not consistently preserve subtype of the ndarray,
is this known behaviour or should I file a bug for it?

Python 2.7.3 (default, Sep 26 2012, 21:51:14)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> import numpy as np
 >>> np.version.version
'1.7.0'
 >>> a=np.matrix(range(10))
 >>> a.round(decimals=10)
matrix([[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]])
 >>> a.round(decimals=-10)
array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]])

Matti



More information about the NumPy-Discussion mailing list