Skip to content

Commit

Permalink
Merge branch 'issue-260' into main; Closes #260
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinsimpson committed Mar 11, 2024
2 parents eba6d42 + 77f9dc5 commit 1d98f91
Show file tree
Hide file tree
Showing 14 changed files with 608 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: gratia
Version: 0.8.9.9
Version: 0.8.9.10
Date: 2024-03-11
Title: Graceful 'ggplot'-Based Graphics and Other Functions for GAMs Fitted Using 'mgcv'
Authors@R: c(person(given = "Gavin L.", family = "Simpson",
Expand Down
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# gratia 0.8.9.9
# gratia 0.8.9.10

## Breaking changes

Expand Down Expand Up @@ -343,6 +343,10 @@ to `select` and the function will continue.
variables in `data` but was written in such a way that it would fail when
relocating the data columns to the end of the posterior sampling object. #255

* `draw.gam()` and `draw.smooth_estimates()` would fail when plotting a
univariate tensor product smooth (e.g. `te(x)`, `ti(x)`, or `t2()`). Reported
by @wStockhausen #260

# gratia 0.8.2

* Small fixes for CRAN.
Expand Down
4 changes: 3 additions & 1 deletion R/smooth-estimates.R
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,9 @@
"Mono inc 0 start P spline",
"Mono inc 0 start P spline"
)) {
class(object) <- c("mgcv_smooth", class(object))
class(object) <- append(class(object), "mgcv_smooth", after = 0L)
} else if (grepl("1d Tensor product", sm_type, fixed = TRUE)) {
class(object) <- append(class(object), "mgcv_smooth", after = 0L)
} else if (sm_type == "Random effect") {
class(object) <- append(class(object),
c("random_effect", "mgcv_smooth"),
Expand Down
10 changes: 9 additions & 1 deletion R/smooth-type.R
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@
#' @export
#' @rdname smooth_type
`smooth_type.t2.smooth` <- function(smooth) {
sm_type <- "Tensor product (T2)"
sm_type <- if (identical(smooth_dim(smooth), 1L)) {
"1d Tensor product (T2)"
} else {
"Tensor product (T2)"
}
sm_type
}

Expand All @@ -162,11 +166,15 @@
#' @rdname smooth_type
`smooth_type.tensor.smooth` <- function(smooth) {
inter <- smooth[["inter"]]
sm_dim <- smooth_dim(smooth)
sm_type <- if (isTRUE(inter)) {
"Tensor product int."
} else {
"Tensor product"
}
if (identical(sm_dim, 1L)) {
sm_type <- paste("1d", sm_type)
}
sm_type
}

Expand Down
91 changes: 91 additions & 0 deletions tests/testthat/_snaps/draw-gam/draw-gam-univariate-t2-smooth.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 1d98f91

Please sign in to comment.