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
{{ message }}
Repository navigation
repr change for arrays of size 1 even with np.set_printoptions(legacy=True) in numpy master #10026
It's a feature, not a bug ;) The default print formatting will change in 1.14. We are aware that this will break doctests. From the release notes
Changes to array printing, and the new "legacy" printing mode.
--------------------------------------------------------------
The new ``sign='-'`` option (see new features below) causes the ``repr`` of
float arrays to often omit a whitespace previously printed in the sign
position, and 0d arrays also now print with small whitespace and precision
differences (see changes below). These changes are likely to break downstream
user's doctests.
These new behaviors can be disabled to mostly reproduce numpy 1.13 behavior by
enabling the new "legacy" printing mode. This is enabled by calling
``np.set_printoptions(legacy=True)``, or using the new ``legacy`` argument
to ``np.array2string``.
Note that there are various ways to relax whitespace sensitivity of doctests which are probably worth looking into if you want to continue to rely on doctests. @ahaldane Further suggestions?
Oops, I see that you did use the legacy mode, so we can maybe fix that.
That would be great!
For now our strategy is to use the legacy mode to have compatibility of our doctest with numpy 1.14dev and 1.13. When numpy 1.14 is released we will revisit our strategy. One possible solution is to update all of our doctests to work with 1.14 and just skip them for numpy <= 1.13.
What code exactly printed 0.99999999? There is a new float printing algorithm in 1.14 which, barring a bug, should print just like a python3 float.
There is a case for np.set_printoptions(legacy=True) to implement the pre-dragon4 printing. I am not sure it is worth the cost, I'll open a separate issue to discuss this. FWIW in scikit-learn we have managed to work around these issues by using doctest ellipsis.
Yes, we can discuss that. But if you see a number that is printed as 0.99999999 when it should be printed as 1.0 let us know.
The goal of the new algorithm is to round "correctly" for all float sizes, so if there is an instance where it isn't rounding correctly, that is important.
Activity
charris commentedon Nov 15, 2017
It's a feature, not a bug ;) The default print formatting will change in 1.14. We are aware that this will break doctests. From the release notes
Note that there are various ways to relax whitespace sensitivity of doctests which are probably worth looking into if you want to continue to rely on doctests. @ahaldane Further suggestions?
charris commentedon Nov 15, 2017
Note that there are more changes than you show, for instance
Note missing spaces.
charris commentedon Nov 15, 2017
Oops, I see that you did use the legacy mode, so we can maybe fix that.
lesteve commentedon Nov 15, 2017
That would be great!
For now our strategy is to use the legacy mode to have compatibility of our doctest with numpy 1.14dev and 1.13. When numpy 1.14 is released we will revisit our strategy. One possible solution is to update all of our doctests to work with 1.14 and just skip them for numpy <= 1.13.
amueller commentedon Nov 15, 2017
I'm confused. So did numpy decide to definitely break, regardless of the sign/legacy setting?(this was not the issue I meant to comment on, and this thread actually answered my question, sorry for the noise)
amueller commentedon Nov 15, 2017
Something that was printed as 1.0 is now printed as 0.99999999(...?) is that also a feature?
ahaldane commentedon Nov 15, 2017
What code exactly printed
0.99999999? There is a new float printing algorithm in 1.14 which, barring a bug, should print just like a python3 float.ahaldane commentedon Nov 15, 2017
I'll take a look at the space in the legacy option, I'm pretty sure that is a fixable bug.
lesteve commentedon Nov 15, 2017
There is a case for
np.set_printoptions(legacy=True)to implement the pre-dragon4 printing. I am not sure it is worth the cost, I'll open a separate issue to discuss this. FWIW in scikit-learn we have managed to work around these issues by using doctest ellipsis.ahaldane commentedon Nov 15, 2017
Yes, we can discuss that. But if you see a number that is printed as
0.99999999when it should be printed as1.0let us know.The goal of the new algorithm is to round "correctly" for all float sizes, so if there is an instance where it isn't rounding correctly, that is important.
charris commentedon Nov 19, 2017
Just a quick update, it is now
legacy='1.13'to get the old printing.