-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
MAINT: legacy-printing-mode preserves 1.13 float & complex str #10034
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
Conversation
Would be nice to merge #10030 first, to rebase onto. |
#10030 is in, doesn't seem to need a rebase. |
It needs a small rework, I'll get it done soon. |
3c20cb2
to
88e8fb3
Compare
Updated, should be good now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shame to reintroduce so much old code, but LGTM.
Do you think it would be a good idea toindent the entire section / wrap it in an #ifdef ALLOW_113_LEGACY
or something to make it visually clear it's legacy code?
Yeah maybe I should move all the old code to one big block and surround it by comments "START LEGACY FUNCTIONS" and "END LEGACY FUNCTIONS" instead of interleaving the old code. |
That would be reasonable too. Could also move the definitions to a |
That brings up the question of how we eventually get rid of the legacy code. I suppose we will need to deprecate that option at some point. |
88e8fb3
to
f539150
Compare
All right, I moved it to one big block surrounded by comments. |
Yes, but deprecating it shouldn't be too hard. Just add a warning anytime legacy mode is set durign the deprecation period, and after that raise an exception. I think the scikit-learn devs said they only really needed the legacy mode for 1 or 2 release cycles, just enough time for them to update their tests. Edit: Here's the comment: (link) |
Yeah, deprecation should be straightforward. The key thing is that we need at least one release to be compatible with 1.13, so that dependents don't have to update their tests in lock-step. |
} | ||
else { | ||
char re[64], im[64]; | ||
if (npy_isfinite(val.real)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Four space indents. Did some hard tabs slip in?
LGTM apart from the 8 space indents. |
I'm going to put this in and follow up with a |
Fixes #10029
This PR makes it so legacy mode preserves the truncation behavior for
str(np.floatxx())
, and the*
behavior of complex scalars (eg(1+nan*j)
) from numpy 1.13.The implementation was just to cut-n-paste the old str/repr code from numpy 1.13, with minor modifications to fit it in. Then I add a C global variable which is set in legacy mode, and then use the old str/repr code if it is set.