Skip to content

MAINT: Backcompat fixes for dragon4 changes #10008

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

Merged
merged 2 commits into from
Nov 13, 2017

Conversation

ahaldane
Copy link
Member

This is a small fixup to the dragon4 changes as suggested by @eric-wieser in #9941. This adds back in the FloatFormat classes that I deleted, but deprecates them.

We can also discuss renaming floatmode to float_mode. I didn't do that because, while it is true that some functions here use underscores, others don't. Eg, we already use linewidth and edgeitems in the _format_options dict and as args to set_printoptions. So I'd argue floatmode is the more consistent choice.

It's a little strange we only allow longdouble to be separately customizable as a formatter, and not any of the other float types, but I guess that's the way it is, no real harm in leaving it so.

@@ -403,6 +403,10 @@ elements uniquely.
Numpy complex-floating-scalars with values like ``inf*j`` or ``nan*j`` now
print as ``infj`` and ``nanj``, like the pure-python ``complex`` type.

The ``FloatFormat`` and ``LongFloatFormat`` classes are deprecated and should
both be replaced by ``FloatingFormat``, and similarly ``ComplexFormat`` and
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: might be easier to read as ... . Similarly ...

class LongFloatFormat(FloatingFormat):
def __init__(self, *args, **kwargs):
warnings.warn("LongFloatFormat has been replaced by FloatingFormat",
DeprecationWarning, stacklevel=1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be stacklevel=2? I think we do that elsewhere.

@eric-wieser
Copy link
Member

eric-wieser commented Nov 12, 2017

There's something that sets formatdict['half'] further down - do we need to restore that too, or was it always dead code?

EDIT: Looks like 'half' is new in 1.14, so we should probably either support it or kill it.

@ahaldane
Copy link
Member Author

Thanks, fixed stacklevel and release note.

@eric-wieser
Copy link
Member

Comment about the 'half' formatter still applies. It didn't use to be there at all in 1.13, and now it seems it's there but does nothing. Let's either add it completely, or kill it.

@ahaldane
Copy link
Member Author

OOps, forgot that. Fixed now.

Copy link
Member

@eric-wieser eric-wieser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@@ -996,6 +1020,22 @@ def __call__(self, x):
i = self.imag_format(x.imag)
return r + i + 'j'

# for back-compatibility, we keep the classes for each float type too
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: complex type too

@eric-wieser eric-wieser merged commit f81dfcc into numpy:master Nov 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants