Skip to content

when testing if an identifier refers to a calculated aesthetic, check the whole identifier, not a substring #917

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 4 commits into from
Feb 25, 2014

Conversation

krlmlr
Copy link
Member

@krlmlr krlmlr commented Feb 25, 2014

Reissue of #835.

@hadley
Copy link
Member

hadley commented Feb 25, 2014

  • Motivate the change in one paragraph, and include it in NEWS.
    In parenthesis, reference your github user name and this issue:
    (@hadley, #1234)
  • Check pull request only includes relevant changes.
  • Use the official style.
  • Add test, if bug in non-graphical function

For the NEWS item, I think you can rewrite to: "Previously aes() incorrectly treated variables like a..x..b as a calculated aesthetic`. Would you mind adding a test?

Kirill Müller added 2 commits February 25, 2014 16:17
… the whole identifier, not a substring

also, define the regex that is used for matching only once, in a hidden global variable

fixes #834

Conflicts:
	R/layer.r

Resolved by combining.
@krlmlr
Copy link
Member Author

krlmlr commented Feb 25, 2014

Added test, updated NEWS, force-pushed. The test for the first commit is supposed to fail.

context("Layer")

test_that("Correctly decide if a variable is a calculated aesthetic", {
expect_true(ggplot2:::is_calculated_aes(aes(x=..density..)))
Copy link
Member

Choose a reason for hiding this comment

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

Tests are run in the package namespace, so you don't need ggplot2:::

Copy link
Member Author

Choose a reason for hiding this comment

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

Doh. Fixed.

I just haven't found a good workflow for running new tests from within RStudio (without building the package or remembering difficult testthat function calls). How do you test new tests?

hadley added a commit that referenced this pull request Feb 25, 2014
when testing if an identifier refers to a calculated aesthetic, check the whole identifier, not a substring
@hadley hadley merged commit 02fdb3e into tidyverse:master Feb 25, 2014
@hadley
Copy link
Member

hadley commented Feb 25, 2014

Thanks!

@krlmlr krlmlr deleted the fix/834-calculated-dots-2 branch February 25, 2014 15:37
@hadley
Copy link
Member

hadley commented Mar 21, 2014

@krlmlr Could you please take at the check failures in https://github.com/wch/ggplot2-checkresults/blob/master/r-release/00check-summary.txt ?

@wch
Copy link
Member

wch commented Mar 21, 2014

This probably isn't the source of this problem, but it does look like a bug. The regex should have have a-zA-Z instead of a-zA-z. The latter includes a bunch of characters between the upper and lower case letters: http://www.ascii-code.com/

@krlmlr
Copy link
Member Author

krlmlr commented Mar 22, 2014

Thanks for catching the regex glitch, this was a copy-paste error. Harmless, but should be tested for and fixed anyway.

I can bisect to search for a commit that introduces the error. It's only running R CMD check on the CRAN versions of the affected packages, right?

@hadley
Copy link
Member

hadley commented Mar 22, 2014

Right. I can't how see your change would have broken this but it seems the most likely hypothesis.

@krlmlr
Copy link
Member Author

krlmlr commented Mar 23, 2014

The bbmle package passes checks if I remove ^ and $ from the regular expression. It seems that the regular expression should also match substrings. I think it's possible to obtain the desired behavior with the help of lookarounds, but I wonder if it's really worth it.

@lock
Copy link

lock bot commented Jan 19, 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 19, 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.

3 participants