[Numpy-discussion] Change in ``round`` behavior for numpy scalars in python 3

Matthew Brett matthew.brett at gmail.com
Sat Sep 15 09:15:36 EDT 2012


I just noticed that Python 3 raises an error for 0 dimensional numpy
arrays.  Here's Python 2.6:

In [14]: a = np.array(1.1)

In [15]: round(a)
Out[15]: 1.0

and Python 3.2:

In [3]: a = np.array(1.1)

In [4]: round(a)
TypeError                                 Traceback (most recent call last)
/Users/mb312/dev_trees/<ipython-input-4-7736a3ba67a1> in <module>()
----> 1 round(a)

TypeError: type numpy.ndarray doesn't define __round__ method

Should arrays implement __round__ ?    Returning an error for 1D or above?



More information about the NumPy-Discussion mailing list