-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Floating point repr #6136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Yeah, this bugs me a bit too :-). The complication though is that when
|
It's already space-padded:
|
Array printing passes through separate code from scalar repr. In fact, repr on arrays intentionally does not produce an invertible representation of the array (it prints according to printoptions). But this could be fixed for np.float64 without too much difficulty. np.float32 could be converted to double, which will sometimes produce more digits than necessary for inversion. np.longdouble can't go through python floats, so it would require implementing the algorithm to get a tidy representation; probably not worth it. The code would go in numpy/core/src/multiarray/scalartypes.c.src in the templated function @name@type_@kind@; the repr version would just convert to a python float and use repr. |
I think it would be better to write the same kind of type-precision respecting print that Python has rather than trying to go through Python's float-printing code. It would be nice for |
Closed by #9941 |
Python floats use the shortest repr that give the same value when eval'd since https://bugs.python.org/issue1580 was accepted. It would be nice if numpy did the same.
I realize it would require a nontrivial patch :)
The text was updated successfully, but these errors were encountered: