thouis / numpy-trac-migration

numpy Trac to github issues migration
2 stars 3 forks source link

numpy.round() doesn't work on zero dimensional vectors or floats (Trac #2141) #5937

Open numpy-gitbot opened 12 years ago

numpy-gitbot commented 12 years ago

Original ticket http://projects.scipy.org/numpy/ticket/2141 on 2012-05-23 by atmention:pbrod, assigned to unknown.

as shown in the following example:

In [12]: np.__version__
Out[12]: '1.6.1'

In [13]: np.round(3.434523, decimals=3)
Out[13]: 3.4350000000000001

In [14]: np.round(np.array(3.434523), decimals=3)
Out[14]: 3.4350000000000001

However, correct result is obtained when the value is converted to a one dimensional array, as shown here:

In [15]: np.round([3.434523], decimals=3)
Out[15]: array([ 3.435])

In [16]: np.round(np.array([3.434523]), decimals=3)
Out[16]: array([ 3.435])

A related issue is Ticket #1648