-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Define non_missing_aes for GeomCol and GeomBar. Closes #2715. #2719
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
Conversation
Could we have a unit test for this? |
In theory yes, in practice I'm running into a strange issue of not being able to test for warnings that are clearly happening. Will post a reprex later today. |
Here is the reprex. I have no idea what is happening. library(ggplot2)
library(testthat)
dat <- data.frame(x = c(1, 2, 3))
bplot <- function(extra = list()) {
ggplot_build(ggplot(dat, aes(x, x)) + geom_col() + extra)
}
# prints warning at the end
bplot(ylim(0.5, 4))
#> $data
#> $data[[1]]
#> y x PANEL group ymin ymax xmin xmax colour fill size linetype alpha
#> 1 1 1 1 -1 NA 1 0.55 1.45 NA grey35 0.5 1 NA
#> 2 2 2 1 -1 NA 2 1.55 2.45 NA grey35 0.5 1 NA
#> 3 3 3 1 -1 NA 3 2.55 3.45 NA grey35 0.5 1 NA
#>
#>
#> $layout
#> <ggproto object: Class Layout, gg>
#> coord: <ggproto object: Class CoordCartesian, Coord, gg>
#> aspect: function
#> clip: on
#> default: TRUE
#> distance: function
#> expand: TRUE
#> is_free: function
#> is_linear: function
#> labels: function
#> limits: list
#> modify_scales: function
#> range: function
#> render_axis_h: function
#> render_axis_v: function
#> render_bg: function
#> render_fg: function
#> setup_data: function
#> setup_layout: function
#> setup_panel_params: function
#> setup_params: function
#> transform: function
#> super: <ggproto object: Class CoordCartesian, Coord, gg>
#> coord_params: list
#> facet: <ggproto object: Class FacetNull, Facet, gg>
#> compute_layout: function
#> draw_back: function
#> draw_front: function
#> draw_labels: function
#> draw_panels: function
#> finish_data: function
#> init_scales: function
#> map_data: function
#> params: list
#> setup_data: function
#> setup_params: function
#> shrink: TRUE
#> train_scales: function
#> vars: function
#> super: <ggproto object: Class FacetNull, Facet, gg>
#> facet_params: list
#> finish_data: function
#> get_scales: function
#> layout: data.frame
#> map_position: function
#> panel_params: list
#> panel_scales_x: list
#> panel_scales_y: list
#> render: function
#> render_labels: function
#> reset_scales: function
#> setup: function
#> setup_panel_params: function
#> train_position: function
#> xlabel: function
#> ylabel: function
#> super: <ggproto object: Class Layout, gg>
#>
#> $plot
#> Warning: Removed 3 rows containing missing values (geom_col).
Created on 2018-06-27 by the reprex package (v0.2.0). |
The warning is only generated when |
Actually, yes, just figured it out. The warning happens at the drawing stage, so just building the plot is not enough to trigger it. |
Regression tests added. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My only concern is that rendering the plot is slow, so I'm not sure if having 4 tests is worth the added cost to unit test run time.
I believe there are some unit tests for which rendering is not needed, because the warning is created before the plot is rendered. I will rework the tests so they render only when absolutely needed. |
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/ |
Define non_missing_aes for GeomCol and GeomBar. Closes #2715.