Skip to content

Commit

Permalink
Fix bug on glimpse
Browse files Browse the repository at this point in the history
  • Loading branch information
dieghernan committed Apr 24, 2024
1 parent 3059381 commit 83502cb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions R/glimpse-Spat.R
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ dplyr::glimpse
get_named_crs <- function(x) {
# Based in terra:::.name_or_proj4()
pulled <- pull_crs(x)
if (is.na(pulled)) {
return(NA)
}

d <- try(terra::crs(pulled, describe = TRUE), silent = TRUE)

Expand Down
12 changes: 12 additions & 0 deletions tests/testthat/_snaps/glimpse-Spat.md
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,18 @@
$ lyr.1 <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1~

---

Code
glimpse(r1)
Output
# A SpatRaster 4 x 3 x 1 layer (12 cells)
# Resolution (x / y): (1 / 1)
# CRS: Not Defined / Empty
# Extent (x / y) : ([0 / 3] , [0 / 4])
$ lyr.1 <int> 1, 2, 3, 2, 3, 1, 3, 1, 2, 1, 2, 3

# Long geoms

Code
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test-glimpse-Spat.R
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ test_that("NA crs", {
expect_true(is.na(pull_crs(v)))

expect_snapshot(glimpse(v))

# Error detected in #148
r1 <- terra::rast(matrix(rep(1:3, 4), nrow = 4))
expect_snapshot(glimpse(r1))
})


Expand Down

0 comments on commit 83502cb

Please sign in to comment.