You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Related to (but different from) #6136: float64.__str__ can truncate different floats to the same string, even when printoptions is set to a high enough precision:
In [12]: np.set_printoptions(precision=1000)
In [13]: x = np.float64(0.20000000000000004)
In [14]: x > np.float64(.2)
Out[14]: True
In [15]: str(x)
Out[15]: '0.2' # oops
Note that repr(x) correctly gives '0.20000000000000004'.
I don't know of anyone who is. Generally, IIUC the etiquette is that unless someone is really talking about it or has already opened a PR to fix the issue, it is completely up for grabs by anyone. So go for it! Good luck!
It seems the printoptions are set in numpy/core/arrayprint.py. It has functions defined for printing an array but not single numpy values. Is this behavior intended? I mean is printoptions set to work only for arrays? Here is link to an answered question on stackoverflow. Please tell me if I am missing something
Judging from the labeling by @rgommers , I suspect not. I think you may very well have to add a good amount of new code in order to enforce printing for numbers.
You still have to cast a as an array object. It's just one without a shape, so the function still does not apply to pure literals like a = 5 for example.
I just ran into this issue. printoptions should be respected by all three:
In [21]: np.set_printoptions(precision=3)
In [22]: print(np.ones(()) * (0.123456789123))
0.123456789123
In [23]: print(np.float32(0.123456789123))
0.123457
In [24]: print(np.ones((1,)) * (0.123456789123))
[ 0.123]
Activity
gfyoung commentedon Jan 12, 2016
Is it me, or are the print options only respected when we want to print arrays? Here's another example of "bad" behavior with scalars:
sam09 commentedon Jan 16, 2016
Is anyone working on this issue?
If not i would like to give it a go
gfyoung commentedon Jan 16, 2016
I don't know of anyone who is. Generally, IIUC the etiquette is that unless someone is really talking about it or has already opened a PR to fix the issue, it is completely up for grabs by anyone. So go for it! Good luck!
anntzer commentedon Jan 16, 2016
Please consider fixing #6136 at the same time :)
sam09 commentedon Jan 20, 2016
It seems the
printoptionsare set innumpy/core/arrayprint.py. It has functions defined for printing an array but not single numpy values. Is this behavior intended? I mean is printoptions set to work only for arrays? Here is link to an answered question on stackoverflow. Please tell me if I am missing somethinggfyoung commentedon Jan 20, 2016
Judging from the labeling by @rgommers , I suspect not. I think you may very well have to add a good amount of new code in order to enforce printing for numbers.
sam09 commentedon Jan 25, 2016
I think the float values are also printed by array2string function defined in
numpy/core/arrayprint.py.This is where I think it happens
gfyoung commentedon Jan 25, 2016
You still have to cast
aas anarrayobject. It's just one without a shape, so the function still does not apply to pure literals likea = 5for example.NeilGirdhar commentedon May 18, 2016
I just ran into this issue. printoptions should be respected by all three:
prints scalars using the same formatters as array elements
ahaldane commentedon Nov 5, 2017
Closed by #9941