Skip to content
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

Filter out invalid value warnings in log scaling #10480

Merged
merged 1 commit into from Mar 6, 2018

Conversation

Projects
None yet
5 participants
@dstansby
Copy link
Contributor

commented Feb 15, 2018

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

This comment has been minimized.

Copy link
Contributor

commented Feb 15, 2018

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

@dstansby dstansby force-pushed the dstansby:logscale-np-warning branch from 9cf6be5 to 4bf36eb Feb 19, 2018

@efiring
Copy link
Member

left a comment

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"):

This comment has been minimized.

Copy link
@efiring

efiring Feb 20, 2018

Member

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).

Filter out invalid value warnings in log scaling
Wrap all logscaling in ignore invalid values

@dstansby dstansby force-pushed the dstansby:logscale-np-warning branch from 4bf36eb to 6f24660 Mar 4, 2018

@jklymak jklymak modified the milestones: v3.0, v2.2.1 Mar 6, 2018

@jklymak jklymak merged commit 5cb2205 into matplotlib:master Mar 6, 2018

8 checks passed

ci/circleci: docs-python35 Your tests passed on CircleCI!
Details
ci/circleci: docs-python36 Your tests passed on CircleCI!
Details
codecov/patch 100% of diff hit (target 50%)
Details
codecov/project/library 67.41% (target 50%)
Details
codecov/project/tests 98.54% remains the same compared to 438aa08
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
lgtm analysis: Python No alert changes
Details

meeseeksdev bot pushed a commit that referenced this pull request Mar 6, 2018

@dstansby dstansby deleted the dstansby:logscale-np-warning branch Mar 6, 2018

dstansby added a commit that referenced this pull request Mar 6, 2018

@QuLogic QuLogic added Needs review and removed Needs review labels Mar 23, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.