forked from Open-Systems-Pharmacology/TLF-Library
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes Open-Systems-Pharmacology#381 Prevent log ticks from crashing p…
…lots (Open-Systems-Pharmacology#382)
- Loading branch information
Showing
7 changed files
with
169 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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,31 @@ | ||
isLogTicksIncludedInLimits <- tlf:::.isLogTicksIncludedInLimits | ||
|
||
test_that("isLogTicksIncludedInLimits checks work as expected", { | ||
expect_true(isLogTicksIncludedInLimits(limits = 1, scale = Scaling$log)) | ||
expect_true(isLogTicksIncludedInLimits(limits = 1, scale = Scaling$ln)) | ||
expect_true(isLogTicksIncludedInLimits(limits = 10, scale = Scaling$log)) | ||
expect_true(isLogTicksIncludedInLimits(limits = exp(1), scale = Scaling$ln)) | ||
|
||
expect_true(isLogTicksIncludedInLimits(limits = c(5, 15), scale = Scaling$log)) | ||
expect_true(isLogTicksIncludedInLimits(limits = c(5, 15), scale = Scaling$ln)) | ||
|
||
expect_false(isLogTicksIncludedInLimits(limits = c(32, 33), scale = Scaling$log)) | ||
expect_false(isLogTicksIncludedInLimits(limits = c(32, 33), scale = Scaling$ln)) | ||
|
||
}) | ||
|
||
|
||
test_that("A plot with log ticks do not crash when isLogTicksIncludedInLimits is false", { | ||
testPlot <- addScatter(x=c(31,32),y=c(31,32)) | ||
expect_silent(print(setXAxis(testPlot, scale = Scaling$log))) | ||
expect_silent(print(setYAxis(testPlot, scale = Scaling$log))) | ||
expect_silent(print(setXAxis(testPlot, scale = Scaling$ln))) | ||
expect_silent(print(setYAxis(testPlot, scale = Scaling$ln))) | ||
|
||
# If a classical plot is used, an error would be obtained as in the example below | ||
# testPlot <- ggplot( | ||
# data.frame(x=c(31,32),y=c(31,32)), | ||
# aes(x=x,y=y)) + | ||
# geom_point() + scale_y_log10() + annotation_logticks() | ||
# expect_error(print(testPlot)) | ||
}) |