Skip to content

Commit

Permalink
use reordered dims properly for #680
Browse files Browse the repository at this point in the history
  • Loading branch information
dblodgett-usgs committed Apr 24, 2024
1 parent d291c13 commit 367cc64
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion R/ncdf.R
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ read_ncdf = function(.x, ..., var = NULL, ncsub = NULL, curvilinear = character(

# Create stars dimensions object

if(is.null(nc_dim <- dim(out_data[[1]]))) nc_dim <- dims$length
nc_dim <- dims$count

dimensions <- create_dimensions(setNames(nc_dim, dims$name),
raster)
Expand Down
12 changes: 10 additions & 2 deletions tests/testthat/test-ncdf.R
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,17 @@ test_that("axis attribute order -- see #680", {

s2 <- suppressWarnings(stars::read_ncdf(file2))

expect_equal(names(stars::st_dimensions(s2)), c("lon", "lat", "time"))
d <- stars::st_dimensions(s2)

expect_equal(names(d), c("lon", "lat", "time"))

expect_equal(d$time$to, 9)

s3 <- suppressWarnings(stars::read_ncdf(file3))

expect_equal(names(stars::st_dimensions(s3)), c("lon", "lat", "time"))
d <- stars::st_dimensions(s2)

expect_equal(names(d), c("lon", "lat", "time"))

expect_equal(d$time$to, 9)
})

0 comments on commit 367cc64

Please sign in to comment.