Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Filter out invalid value warnings in log scaling #10480

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 1 commit into from
Mar 6, 2018

Conversation

dstansby
Copy link
Member

Currently in LogTransformBase the line out[a <= 0] = -1000 will raise a numpy warning if a contains nans. This PR filters out this warning, which seems reasonable since it's also done a few lines earlier, and log-scaling with data that includes nans should probably work without errors or warnings.

@anntzer
Copy link
Contributor

anntzer commented Feb 15, 2018

Perhaps you can just protect the whole function in a single errstate block?

@dstansby dstansby force-pushed the logscale-np-warning branch from 9cf6be5 to 4bf36eb Compare February 19, 2018 13:26
Copy link
Member

@efiring efiring left a comment

Choose a reason for hiding this comment

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

A minor tweak could be applied, but I won't insist on it.

@@ -98,25 +98,26 @@ def __init__(self, nonpos='clip'):
self._clip = {"clip": True, "mask": False}[nonpos]

def transform_non_affine(self, a):
# Ignore invalid values due to nans being passed to the transform
with np.errstate(divide="ignore", invalid="ignore"):
Copy link
Member

Choose a reason for hiding this comment

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

It's not hurting anything, but I don't think the "divide" kwarg is needed, since the only division is by np.log(self.base).

Wrap all logscaling in ignore invalid values
@dstansby dstansby force-pushed the logscale-np-warning branch from 4bf36eb to 6f24660 Compare March 4, 2018 13:56
@jklymak jklymak modified the milestones: v3.0, v2.2.1 Mar 6, 2018
@jklymak jklymak merged commit 5cb2205 into matplotlib:master Mar 6, 2018
@dstansby dstansby deleted the logscale-np-warning branch March 6, 2018 09:13
dstansby added a commit that referenced this pull request Mar 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.