Skip to content

Commit

Permalink
clean test output
Browse files Browse the repository at this point in the history
  • Loading branch information
edzer committed Apr 5, 2024
1 parent ec9e76f commit c645e77
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 72 deletions.
2 changes: 1 addition & 1 deletion man/st_extract.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions tests/aggregate.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
## IGNORE_RDIFF_BEGIN
library(stars)
## IGNORE_RDIFF_END

if (suppressPackageStartupMessages(require(sp, quietly = TRUE)) && require(spacetime, quietly = TRUE)) {
data(air) # this loads several datasets in .GlobalEnv
Expand Down
10 changes: 6 additions & 4 deletions tests/aggregate.Rout.save
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

R version 4.3.1 (2023-06-16) -- "Beagle Scouts"
Copyright (C) 2023 The R Foundation for Statistical Computing
R version 4.3.3 (2024-02-29) -- "Angel Food Cake"
Copyright (C) 2024 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
Expand All @@ -15,10 +15,12 @@ Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> ## IGNORE_RDIFF_BEGIN
> library(stars)
Loading required package: abind
Loading required package: sf
Linking to GEOS 3.11.1, GDAL 3.6.2, PROJ 9.1.1; sf_use_s2() is TRUE
Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.3.1; sf_use_s2() is TRUE
> ## IGNORE_RDIFF_END
>
> if (suppressPackageStartupMessages(require(sp, quietly = TRUE)) && require(spacetime, quietly = TRUE)) {
+ data(air) # this loads several datasets in .GlobalEnv
Expand Down Expand Up @@ -199,4 +201,4 @@ t NULL
>
> proc.time()
user system elapsed
5.664 0.832 5.605
4.734 1.325 4.640
4 changes: 2 additions & 2 deletions tests/mdim.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ s = st_set_dimensions(s, st_dimensions(s), xy = NULL)
sfc = st_sfc(st_point(0:1), st_point(3:2))
s = st_set_dimensions(s, 1, sfc) |> st_set_crs(4326)
tm = as.POSIXct("2023-03-04 12:35") + c(0, 3600)
(s = st_set_dimensions(s, 2, tm))
s = st_set_dimensions(s, 2, tm)
f = tempfile(fileext = ".nc")
write_mdim(s, f, as_float = FALSE)
s2 = read_mdim(f)
print(s2)
#print(s2)
print(all.equal(s, s2, check.attributes = FALSE))
print(all.equal(s, s2))

Expand Down
32 changes: 5 additions & 27 deletions tests/mdim.Rout.save
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

R version 4.3.2 (2023-10-31) -- "Eye Holes"
Copyright (C) 2023 The R Foundation for Statistical Computing
R version 4.3.3 (2024-02-29) -- "Angel Food Cake"
Copyright (C) 2024 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
Expand Down Expand Up @@ -28,18 +28,7 @@ Type 'q()' to quit R.
> sfc = st_sfc(st_point(0:1), st_point(3:2))
> s = st_set_dimensions(s, 1, sfc) |> st_set_crs(4326)
> tm = as.POSIXct("2023-03-04 12:35") + c(0, 3600)
> (s = st_set_dimensions(s, 2, tm))
stars object with 2 dimensions and 1 attribute
attribute(s):
Min. 1st Qu. Median Mean 3rd Qu. Max.
A1 1 1.75 2.5 2.5 3.25 4
dimension(s):
from to offset delta refsys point
X1 1 2 NA NA WGS 84 TRUE
X2 1 2 2023-03-04 12:35:00 UTC 1 hours POSIXct FALSE
values
X1 POINT (0 1), POINT (3 2)
X2 NULL
> s = st_set_dimensions(s, 2, tm)
> f = tempfile(fileext = ".nc")
> write_mdim(s, f, as_float = FALSE)
Warning messages:
Expand All @@ -48,18 +37,7 @@ Warning messages:
2: In CPL_write_mdim(file, driver, dimx, cdl, wkt, xy, root_group_options, :
GDAL Error 6: SetIndexingVariable() not implemented
> s2 = read_mdim(f)
> print(s2)
stars object with 2 dimensions and 1 attribute
attribute(s):
Min. 1st Qu. Median Mean 3rd Qu. Max.
A1 1 1.75 2.5 2.5 3.25 4
dimension(s):
from to offset delta refsys point
X1 1 2 NA NA WGS 84 TRUE
X2 1 2 2023-03-04 12:35:00 UTC 1 hours POSIXct NA
values
X1 POINT (0 1), POINT (3 2)
X2 NULL
> #print(s2)
> print(all.equal(s, s2, check.attributes = FALSE))
[1] TRUE
> print(all.equal(s, s2))
Expand Down Expand Up @@ -120,4 +98,4 @@ X2 1 2 2023-02-25 1 days Date NA NULL
>
> proc.time()
user system elapsed
0.868 1.330 0.699
0.828 1.229 0.624
2 changes: 1 addition & 1 deletion tests/stars.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ st_apply(x, 1:2, range)
geomatrix = system.file("tif/geomatrix.tif", package = "stars")
x = read_stars(geomatrix)
y = st_transform(x, st_crs(4326))
st_coordinates(x)[1:10,]
st_coordinates(x)[1:2,]

nc = system.file("nc/tos_O1_2001-2002.nc", package = "stars")
if (nc != "" && require(PCICt, quietly = TRUE)) {
Expand Down
22 changes: 7 additions & 15 deletions tests/stars.Rout.save
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

R version 4.3.2 (2023-10-31) -- "Eye Holes"
Copyright (C) 2023 The R Foundation for Statistical Computing
R version 4.3.3 (2024-02-29) -- "Angel Food Cake"
Copyright (C) 2024 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
Expand Down Expand Up @@ -219,18 +219,10 @@ y 1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y]
> geomatrix = system.file("tif/geomatrix.tif", package = "stars")
> x = read_stars(geomatrix)
> y = st_transform(x, st_crs(4326))
> st_coordinates(x)[1:10,]
x y
1 1841000 1144000
2 1841002 1143995
3 1841003 1143990
4 1841004 1143985
5 1841006 1143980
6 1841008 1143975
7 1841009 1143970
8 1841010 1143965
9 1841012 1143960
10 1841014 1143955
> st_coordinates(x)[1:2,]
x y
1 1841000 1144000
2 1841002 1143995
>
> nc = system.file("nc/tos_O1_2001-2002.nc", package = "stars")
> if (nc != "" && require(PCICt, quietly = TRUE)) {
Expand Down Expand Up @@ -499,4 +491,4 @@ X1 1 1 FALSE 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
>
> proc.time()
user system elapsed
4.614 1.291 4.652
4.556 1.375 4.532
2 changes: 2 additions & 0 deletions tests/transform.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ plot(st_transform(st_as_sfc(x, as_points=FALSE), new), add = TRUE)
tif = system.file("tif/L7_ETMs.tif", package = "stars")
x = read_stars(tif)[,1:10,1:10,1:3]
x_ = st_transform(x, st_crs(4326))
## IGNORE_RDIFF_BEGIN
if (require(lwgeom, quietly = TRUE)) {
x__ = st_transform_proj(x, st_crs(4326)$proj4string)
st_crs(x_) = st_crs(x__)
Expand All @@ -26,6 +27,7 @@ if (require(lwgeom, quietly = TRUE)) {
(x__ = st_transform_proj(x, st_crs(4326)))
print(all.equal(x_,x__,check.attributes = FALSE))
}
## IGNORE_RDIFF_END

# nothing to transform: now errs:
try(st_transform(st_as_stars(list(m = matrix(1,10,10))), st_crs(4326)))
Expand Down
8 changes: 5 additions & 3 deletions tests/transform.Rout.save
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

R version 4.3.2 (2023-10-31) -- "Eye Holes"
Copyright (C) 2023 The R Foundation for Statistical Computing
R version 4.3.3 (2024-02-29) -- "Angel Food Cake"
Copyright (C) 2024 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
Expand Down Expand Up @@ -39,6 +39,7 @@ sheared raster with parameters: -5 -5
> tif = system.file("tif/L7_ETMs.tif", package = "stars")
> x = read_stars(tif)[,1:10,1:10,1:3]
> x_ = st_transform(x, st_crs(4326))
> ## IGNORE_RDIFF_BEGIN
> if (require(lwgeom, quietly = TRUE)) {
+ x__ = st_transform_proj(x, st_crs(4326)$proj4string)
+ st_crs(x_) = st_crs(x__)
Expand All @@ -62,6 +63,7 @@ The following object is masked from 'package:sf':

[1] TRUE
[1] TRUE
> ## IGNORE_RDIFF_END
>
> # nothing to transform: now errs:
> try(st_transform(st_as_stars(list(m = matrix(1,10,10))), st_crs(4326)))
Expand All @@ -73,4 +75,4 @@ Error in st_transform_proj.stars(st_as_stars(list(m = matrix(1, 10, 10))), :
>
> proc.time()
user system elapsed
1.100 1.306 0.938
1.020 1.298 0.824
6 changes: 3 additions & 3 deletions tests/warp.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ st_dimensions(x1p)
(x1b = setNames(st_warp(x1, x1p, use_gdal = TRUE, no_data_value=-1), "file.tif"))

# does gdal reproduce what stars does? Smaller grid:
(x2 = st_warp(x, crs = st_crs(x), use_gdal = FALSE, cellsize = 3))
x2 = st_warp(x, crs = st_crs(x), use_gdal = FALSE, cellsize = 3)
# x2 = x2[,2:43,2:43]
if (interactive()) { plot(x2, breaks = "equal", axes=TRUE, reset = FALSE) }
if (interactive()) { plot(st_as_sfc(st_bbox(x2)), add = TRUE, col = NA, border = 'red') }
Expand All @@ -36,8 +36,8 @@ if (interactive()) { plot(st_as_sfc(st_bbox(x2)), add = TRUE, col = NA, border =
if (interactive()) { plot(y, breaks = "equal") }
names(x2) = names(y)
# isTRUE(all.equal(x2, y, check.attributes=FALSE))
mean(as.vector(x2[[1]]==y[[1]]), na.rm = TRUE)
unique(as.vector(x2[[1]]-y[[1]]))
m = mean(as.vector(x2[[1]]==y[[1]]), na.rm = TRUE)
u = unique(as.vector(x2[[1]]-y[[1]]))

g = st_as_stars()
attr(g, "dimensions")$x$offset = 0
Expand Down
22 changes: 6 additions & 16 deletions tests/warp.Rout.save
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

R version 4.3.2 (2023-10-31) -- "Eye Holes"
Copyright (C) 2023 The R Foundation for Statistical Computing
R version 4.3.3 (2024-02-29) -- "Angel Food Cake"
Copyright (C) 2024 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
Expand Down Expand Up @@ -101,15 +101,7 @@ y 1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y]
band 1 6 NA NA NA NA
>
> # does gdal reproduce what stars does? Smaller grid:
> (x2 = st_warp(x, crs = st_crs(x), use_gdal = FALSE, cellsize = 3))
stars object with 2 dimensions and 1 attribute
attribute(s):
Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
geomatrix.tif 74 107 123 126.7262 132 255 727
dimension(s):
from to offset delta refsys x/y
x 1 44 1840902 3 WGS 84 / UTM zone 11N [x]
y 1 44 1144003 -3 WGS 84 / UTM zone 11N [y]
> x2 = st_warp(x, crs = st_crs(x), use_gdal = FALSE, cellsize = 3)
> # x2 = x2[,2:43,2:43]
> if (interactive()) { plot(x2, breaks = "equal", axes=TRUE, reset = FALSE) }
> if (interactive()) { plot(st_as_sfc(st_bbox(x2)), add = TRUE, col = NA, border = 'red') }
Expand All @@ -126,10 +118,8 @@ y 1 44 1144003 -3 WGS 84 / UTM zone 11N FALSE [y]
> if (interactive()) { plot(y, breaks = "equal") }
> names(x2) = names(y)
> # isTRUE(all.equal(x2, y, check.attributes=FALSE))
> mean(as.vector(x2[[1]]==y[[1]]), na.rm = TRUE)
[1] 0.9975186
> unique(as.vector(x2[[1]]-y[[1]]))
[1] NA 0 25 49 8
> m = mean(as.vector(x2[[1]]==y[[1]]), na.rm = TRUE)
> u = unique(as.vector(x2[[1]]-y[[1]]))
>
> g = st_as_stars()
> attr(g, "dimensions")$x$offset = 0
Expand All @@ -142,4 +132,4 @@ y 1 44 1144003 -3 WGS 84 / UTM zone 11N FALSE [y]
>
> proc.time()
user system elapsed
1.732 2.471 1.376
1.465 2.300 1.108

0 comments on commit c645e77

Please sign in to comment.