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

warn instead of error for -Inf with log scale #170

Merged
merged 4 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: animint2
Title: Animated Interactive Grammar of Graphics
Version: 2024.11.11
Version: 2024.11.27
URL: https://animint.github.io/animint2/
BugReports: https://github.com/animint/animint2/issues
Authors@R: c(
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Changes in version 2024.11.27 (PR#170)

- When scale_log10 changes -Inf to NA, Inf handling logic now works
(previous was error, user should still fix their code to change -Inf
to 0).

# Changes in version 2024.11.11 (PR#166)

- if(require(maps)) in test-compiler-animation.R.
Expand Down
4 changes: 4 additions & 0 deletions R/geom-.r
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,10 @@ Geom <- gganimintproto("Geom",
extreme.vec <- range.mat[row.i, panel.vec]
cmp <- cmp.list[[row.i]]
to.rep <- cmp(xy.col.df, extreme.vec)
repNA <- is.na(to.rep)
if(any(repNA)){
to.rep[repNA] <- FALSE
}
row.vec <- row(to.rep)[to.rep]
xy.col.df[to.rep] <- extreme.vec[row.vec]
}
Expand Down
21 changes: 21 additions & 0 deletions tests/testthat/test-compiler-errors.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,27 @@ test_that("no warning for no duration vars", {
})
})

test_that("warn for -Inf but not NA input to scale_log10", {
get_viz <- function(value){
animint(
g=ggplot()+
geom_segment(aes(
x, y, xend=xend, yend=yend),
data=data.table(
x=c(value, 0, 1, Inf), xend=10,
y=10, yend=100))+
scale_x_log10())
}
viz_neg_Inf <- get_viz(-Inf)
expect_warning({
animint2dir(viz_neg_Inf, open.browser=FALSE)
}, "NaNs produced")
viz_NA <- get_viz(NA)
expect_no_warning({
animint2dir(viz_NA, open.browser=FALSE)
})
})

test_that("warn no key for geom_text with showSelected=duration var", {
viz.duration <- viz.no.duration
viz.duration$duration <- list(year=2000)
Expand Down
Loading