-
Notifications
You must be signed in to change notification settings - Fork 43
WIP: Fix panel.margin with positive values (#180) #286
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
Open
ANAMASGARD
wants to merge
15
commits into
master
Choose a base branch
from
fix-panel-margin-positive-values
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
dbc1cc5
test: Add failing tests for panel.margin with positive values
ANAMASGARD e122d8d
test: add tests for positive panel.margin values
ANAMASGARD 75b34d0
Added tests for positive panel.margin (fixes #180)
ANAMASGARD 09f0062
Merge branch 'master' into fix-panel-margin-positive-values
ANAMASGARD 7ca1ff3
Merge branch 'master' into fix-panel-margin-positive-values
ANAMASGARD bfe6c8c
Merge branch 'master' into fix-panel-margin-positive-values
ANAMASGARD add8569
test(#180): cover facet_wrap and horizontal facet_grid panel.margin
ANAMASGARD 0891a94
Merge branch 'master' into fix-panel-margin-positive-values
tdhock 2b9d7f2
Merge branch 'master' into fix-panel-margin-positive-values
ANAMASGARD 742928a
Merge branch 'master' into fix-panel-margin-positive-values
ANAMASGARD 7298a72
Merge branch 'master' into fix-panel-margin-positive-values
ANAMASGARD 3d6943f
Merge branch 'master' into fix-panel-margin-positive-values
ANAMASGARD dfc06b8
fix: resolve duplicate Version in DESCRIPTION for CI (PR#286)
ANAMASGARD a83d4e6
docs(NEWS): address tdhock review for panel.margin (PR#286, #180)
ANAMASGARD ac826e8
Removed supported-units paragraph per review
ANAMASGARD File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| acontext("panel.margin with positive values - Issue #180") | ||
| test_that("pt.to.lines handles positive lines unit correctly", { | ||
| lines_value <- grid::unit(2, "lines") | ||
| converted <- pt.to.lines(lines_value) | ||
| expect_true(is.numeric(converted)) | ||
| expect_equal(converted, 2) | ||
| expect_gt(converted, 0) | ||
| }) | ||
| test_that("pt.to.lines handles positive cm unit correctly", { | ||
| cm_value <- grid::unit(0.5, "cm") | ||
| converted <- pt.to.lines(cm_value) | ||
| expect_true(is.numeric(converted)) | ||
| expect_gt(converted, 0) | ||
| expect_equal(as.numeric(cm_value), converted) | ||
| }) | ||
| test_that("pt.to.lines handles positive pt unit correctly", { | ||
| pt_value <- grid::unit(12, "pt") | ||
| converted <- pt.to.lines(pt_value) | ||
| expect_true(is.numeric(converted)) | ||
| expect_gt(converted, 0) | ||
| expect_false(identical(converted, as.numeric(pt_value))) | ||
| expected <- round(as.numeric(pt_value) * (0.25/5.5), digits = 2) | ||
| expect_equal(converted, expected) | ||
| }) | ||
| viz.default <- list( | ||
| p1 = ggplot() + | ||
| geom_point(aes(Petal.Length, Sepal.Length, color = Species), data = iris)) | ||
| test_that("plot_theme extracts panel.margin correctly for default theme", { | ||
| theme.pars <- plot_theme(viz.default$p1) | ||
| panel_margin <- theme.pars$panel.margin | ||
| expect_false(is.null(panel_margin)) | ||
| expect_true(grid::is.unit(panel_margin)) | ||
| }) | ||
| test_that("positive lines preserved through plot_theme and pt.to.lines", { | ||
| viz <- list( | ||
| p1 = ggplot() + | ||
| geom_point(aes(Petal.Length, Sepal.Length, color = Species), data = iris) + | ||
| theme(panel.margin = grid::unit(2, "lines"))) | ||
| theme.pars <- plot_theme(viz$p1) | ||
| panel_margin <- theme.pars$panel.margin | ||
| expect_false(is.null(panel_margin)) | ||
| converted <- pt.to.lines(panel_margin) | ||
| expect_true(is.numeric(converted)) | ||
| expect_equal(converted, 2) | ||
| }) | ||
| test_that("positive cm preserved through plot_theme and pt.to.lines", { | ||
| viz <- list( | ||
| p1 = ggplot() + | ||
| geom_point(aes(Petal.Length, Sepal.Length, color = Species), data = iris) + | ||
| theme(panel.margin = grid::unit(1, "cm"))) | ||
| theme.pars <- plot_theme(viz$p1) | ||
| panel_margin <- theme.pars$panel.margin | ||
| expect_false(is.null(panel_margin)) | ||
| converted <- pt.to.lines(panel_margin) | ||
| expect_true(is.numeric(converted)) | ||
| expect_equal(converted, 1) | ||
| }) | ||
| test_that("zero panel.margin should result in zero spacing", { | ||
| viz <- list( | ||
| p1 = ggplot() + | ||
| geom_point(aes(Petal.Length, Sepal.Length, color = Species), data = iris) + | ||
| theme(panel.margin = grid::unit(0, "lines"))) | ||
| theme.pars <- plot_theme(viz$p1) | ||
| panel_margin <- theme.pars$panel.margin | ||
| converted <- pt.to.lines(panel_margin) | ||
| expect_equal(converted, 0) | ||
| }) | ||
| test_that("positive panel.margin in lines greater than zero", { | ||
| viz.positive <- list( | ||
| p1 = ggplot() + | ||
| geom_point(aes(Petal.Length, Sepal.Length, color = Species), data = iris) + | ||
| theme(panel.margin = grid::unit(2, "lines"))) | ||
| viz.zero <- list( | ||
| p1 = ggplot() + | ||
| geom_point(aes(Petal.Length, Sepal.Length, color = Species), data = iris) + | ||
| theme(panel.margin = grid::unit(0, "lines"))) | ||
| theme.positive <- plot_theme(viz.positive$p1) | ||
| theme.zero <- plot_theme(viz.zero$p1) | ||
| converted.positive <- pt.to.lines(theme.positive$panel.margin) | ||
| converted.zero <- pt.to.lines(theme.zero$panel.margin) | ||
| expect_equal(converted.zero, 0) | ||
| expect_gt(converted.positive, converted.zero) | ||
| expect_equal(converted.positive, 2) | ||
| }) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.