Skip to content

Check for occurence of infinite values #1703

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
Aug 25, 2016

Conversation

thomasp85
Copy link
Member

This change will issue a warning if a transform results in the occurrence of new infinite values. Fixes #1696

@thomasp85 thomasp85 self-assigned this Aug 12, 2016
self$trans$transform(x)
new_x <- self$trans$transform(x)
if (any(is.finite(x) != is.finite(new_x))) {
warning("Transformation introduced infinite values", call. = FALSE)
Copy link
Member

Choose a reason for hiding this comment

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

Can you include the name of the scale in the warning?

@thomasp85
Copy link
Member Author

Added a mention of the scale that throws the warning, but currently all positional scales are called either position_c or position_d - no mention of the axis it pertains to (or the fact that it's a scale).

Don't know if this will confuse more than needed?

@hadley
Copy link
Member

hadley commented Aug 22, 2016

Can you determine "x" vs "y" from the scale object? That would be more useful

@thomasp85
Copy link
Member Author

I can look in the aesthetics fields, but I would rather change the constructors to assigning different names to x and y scales e.g. position_x_d

looking in $aesthetics seems too brittle...

@hadley
Copy link
Member

hadley commented Aug 23, 2016

Using the first aesthetic should be fine. We can fix up later as part of #1312

@thomasp85
Copy link
Member Author

How about this? The resulting warning message will be of the form:

Transformation introduced infinite values in continuous y-axis

@hadley
Copy link
Member

hadley commented Aug 23, 2016

Sounds good. Just needs a bullet in NEWS

@hadley
Copy link
Member

hadley commented Aug 23, 2016

And a unit test or two

@thomasp85
Copy link
Member Author

squash and merge?

@hadley
Copy link
Member

hadley commented Aug 24, 2016

LGTM

Add scale name to warning

Clean up warning
@thomasp85 thomasp85 force-pushed the feature-warn-transform branch from 8cd7cf4 to 27f97d8 Compare August 25, 2016 10:15
@thomasp85 thomasp85 merged commit 9133fd2 into tidyverse:master Aug 25, 2016
@lock
Copy link

lock bot commented Jan 18, 2019

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants