[NumPy-Tickets] [NumPy] #1592: Formatting with arrayprint goes wrong

NumPy Trac numpy-tickets@scipy....
Wed Aug 25 05:45:21 CDT 2010


#1592: Formatting with arrayprint goes wrong
------------------------+---------------------------------------------------
 Reporter:  gaubi       |       Owner:  somebody
     Type:  defect      |      Status:  new     
 Priority:  normal      |   Milestone:          
Component:  numpy.core  |     Version:  1.4.0rc1
 Keywords:  formatting  |  
------------------------+---------------------------------------------------

Old description:

> If there is an array with no number smaller than 1.e-4 and precision is
> set to smaller than 4, values are formatted wrong and printed "0." only:
>
> gaubitzer@asterix:~/test$ python
> Python 2.6.6rc1+ (r266rc1:83691, Aug  5 2010, 17:07:04)
> [GCC 4.4.5 20100728 (prerelease)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import numpy
> >>> a = numpy.array([1.e-3,1.e-4])
> >>> b = numpy.array([1.e-4,1.e-5])
> >>> print a,b
> [ 0.001   0.0001] [  1.00000000e-04   1.00000000e-05]
> >>> numpy.set_printoptions(precision=3)
> >>> print a,b
> [ 0.001  '''0.'''   ] [  1.000e-04   1.000e-05]

New description:

 If there is an array with no number smaller than 1.e-4 and precision is
 set to smaller than 4, values are formatted wrong and printed "0." only:
 {{{
 gaubitzer@asterix:~/test$ python
 Python 2.6.6rc1+ (r266rc1:83691, Aug  5 2010, 17:07:04)
 [GCC 4.4.5 20100728 (prerelease)] on linux2
 Type "help", "copyright", "credits" or "license" for more information.
 >>> import numpy
 >>> a = numpy.array([1.e-3,1.e-4])
 >>> b = numpy.array([1.e-4,1.e-5])
 >>> print a,b
 [ 0.001   0.0001] [  1.00000000e-04   1.00000000e-05]
 >>> numpy.set_printoptions(precision=3)
 >>> print a,b
 [ 0.001  '''0.'''   ] [  1.000e-04   1.000e-05]
 }}}

--

Comment(by rgommers):

 I don't see anything wrong with this. Is your point that you were
 expecting 0.000 instead of 0. ?

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/1592#comment:1>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list