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

Forthcoming ggplot2 release and MTLR #1

Closed
paleolimbot opened this issue May 8, 2019 · 1 comment
Closed

Forthcoming ggplot2 release and MTLR #1

paleolimbot opened this issue May 8, 2019 · 1 comment

Comments

@paleolimbot
Copy link

We're in the process of preparing a ggplot2 release. As part of the release process, we run the R CMD check on packages that use ggplot2 to make sure we don't accidentally break code for downstream packages.

In running the R CMD check on MTLR, we identified the following issue:

  • checking tests ...
     ERROR
    Running the tests in ‘tests/testthat.R’ failed.
    Last 13 lines of output:
      Component "theme": Component 20: target is NULL, current is margin
      Component "theme": Component 21: target is NULL, current is unit
      Component "theme": Component 22: Modes: list, NULL
      ...
      
      ══ testthat results  ═══════════════════════════════════════════════════════════
      OK: 84 SKIPPED: 2 WARNINGS: 35 FAILED: 5
      1. Failure: print and plot functions are consistent for basic survival dataset (@test-method.R#15) 
      2. Failure: plotcurves function is consistent (@test-plotcurves.R#13) 
      3. Failure: plotcurves function is consistent (@test-plotcurves.R#14) 
      4. Failure: plotcurves function is consistent (@test-plotcurves.R#15) 
      5. Failure: plotcurves function is consistent (@test-plotcurves.R#16) 
      
      Error: testthat unit tests failed
      Execution halted
    

These failures are because MTLR is testing the internal structure of ggplot object. This is, in short, a bad idea. In particular, this practice makes it difficult for us to improve ggplot2 without causing your tests to fail.

We suggest testing the output of ggplot2 in using the vdiffr package, which is a tool to manage visual test cases (this is how we test ggplot2). If changes in ggplot2 or your code introduce a change in the visual output of a ggplot, tests will fail when you run them locally. You can use vdiffr as follows:

test_that("output of ggplot() is stable", {
  vdiffr::expect_doppelganger("A blank plot", ggplot())
})

Let me know if I can help! We are hoping to release the next version of ggplot2 in the next two weeks.

@haiderstats
Copy link
Owner

Thanks for letting me know about vdiffr! That is a much more elegant solution for checking the consistency of my plots. Sorry for not getting to this sooner. I changed all the tests to use vdiffr now when testing against the plots.

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

No branches or pull requests

2 participants