Skip to content

Commit 30ef2db

Browse files
Address #133 (#135)
* Address #133 * Try bumping version
1 parent f0dab71 commit 30ef2db

23 files changed

+94
-109
lines changed

.github/workflows/R-CMD-check-hard.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
R_KEEP_PKG_SOURCE: yes
3232

3333
steps:
34-
- uses: actions/checkout@v2
34+
- uses: actions/checkout@v3
3535

3636
- uses: r-lib/actions/setup-pandoc@v2
3737

.github/workflows/R-CMD-check.yaml

+10-10
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ on:
99
branches: [main, master]
1010
pull_request:
1111
branches: [main, master]
12-
workflow_dispatch:
1312

1413
name: R-CMD-check
1514

@@ -23,26 +22,27 @@ jobs:
2322
fail-fast: false
2423
matrix:
2524
config:
26-
- {os: macOS-latest, r: 'release'}
25+
- {os: macos-latest, r: 'release'}
2726

2827
- {os: windows-latest, r: 'release'}
2928
# Use 3.6 to trigger usage of RTools35
3029
- {os: windows-latest, r: '3.6'}
30+
# use 4.1 to check with rtools40's older compiler
31+
- {os: windows-latest, r: '4.1'}
3132

32-
# Use older ubuntu to maximise backward compatibility
33-
- {os: ubuntu-20.04, r: 'devel', http-user-agent: 'release'}
34-
- {os: ubuntu-20.04, r: 'release'}
35-
- {os: ubuntu-20.04, r: 'oldrel-1'}
36-
- {os: ubuntu-20.04, r: 'oldrel-2'}
37-
- {os: ubuntu-20.04, r: 'oldrel-3'}
38-
- {os: ubuntu-20.04, r: 'oldrel-4'}
33+
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
34+
- {os: ubuntu-latest, r: 'release'}
35+
- {os: ubuntu-latest, r: 'oldrel-1'}
36+
- {os: ubuntu-latest, r: 'oldrel-2'}
37+
- {os: ubuntu-latest, r: 'oldrel-3'}
38+
- {os: ubuntu-latest, r: 'oldrel-4'}
3939

4040
env:
4141
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
4242
R_KEEP_PKG_SOURCE: yes
4343

4444
steps:
45-
- uses: actions/checkout@v2
45+
- uses: actions/checkout@v3
4646

4747
- uses: r-lib/actions/setup-pandoc@v2
4848

DESCRIPTION

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ URL: https://github.com/tidymodels/spatialsample,
2121
https://spatialsample.tidymodels.org
2222
BugReports: https://github.com/tidymodels/spatialsample/issues
2323
Depends:
24-
R (>= 3.4)
24+
R (>= 3.5)
2525
Imports:
2626
dplyr (>= 1.0.0),
2727
ggplot2,
@@ -30,6 +30,7 @@ Imports:
3030
rlang (>= 1.0.0),
3131
rsample (>= 1.1.1),
3232
sf (>= 1.0-9),
33+
stats,
3334
tibble,
3435
tidyselect,
3536
units,

NAMESPACE

-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ importFrom(rsample,make_splits)
7575
importFrom(rsample,new_rset)
7676
importFrom(stats,as.dist)
7777
importFrom(stats,cutree)
78-
importFrom(stats,dist)
7978
importFrom(stats,hclust)
8079
importFrom(stats,kmeans)
8180
useDynLib(spatialsample, .registration = TRUE)

R/autoplot.R

+12-7
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@
3737
autoplot.spatial_rset <- function(object, ..., alpha = 0.6) {
3838
bool_id_columns <- grepl("^id", names(object))
3939
# Not sure how this would ever fire, but just in case:
40-
if (sum(bool_id_columns) > 2) rlang::abort(
41-
"Cannot automatically plot rsets with more than two 'id' columns."
42-
)
40+
if (sum(bool_id_columns) > 2) {
41+
rlang::abort(
42+
"Cannot automatically plot rsets with more than two 'id' columns."
43+
)
44+
}
4345
# These are named to not interfere with normal column names
4446
.fold. <- .facet. <- NULL
4547

@@ -90,8 +92,10 @@ autoplot.spatial_rsplit <- function(object, ..., alpha = 0.6) {
9092
object$.class.[outs] <- "Assessment"
9193
object$.class.[is.na(object$.class.)] <- "Buffer"
9294

93-
p <- ggplot2::ggplot(data = object,
94-
mapping = ggplot2::aes(color = .class., fill = .class.))
95+
p <- ggplot2::ggplot(
96+
data = object,
97+
mapping = ggplot2::aes(color = .class., fill = .class.)
98+
)
9599
p <- p + ggplot2::guides(
96100
colour = ggplot2::guide_legend("Class"),
97101
fill = ggplot2::guide_legend("Class")
@@ -107,7 +111,9 @@ autoplot.spatial_rsplit <- function(object, ..., alpha = 0.6) {
107111
autoplot.spatial_block_cv <- function(object, show_grid = TRUE, ..., alpha = 0.6) {
108112
p <- autoplot.spatial_rset(object, ..., alpha = alpha)
109113

110-
if (!show_grid) return(p)
114+
if (!show_grid) {
115+
return(p)
116+
}
111117

112118
data <- object$splits[[1]]$data
113119

@@ -136,5 +142,4 @@ autoplot.spatial_block_cv <- function(object, show_grid = TRUE, ..., alpha = 0.6
136142
# Always prints with "Coordinate system already present. Adding new coordinate system, which will replace the existing one."
137143
# So this silences that
138144
suppressMessages(p + ggplot2::geom_sf(data = grid_blocks, fill = NA))
139-
140145
}

R/buffer.R

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#'
1212
#' @keywords internal
1313
buffer_indices <- function(data, indices, radius, buffer, call = rlang::caller_env()) {
14-
1514
standard_checks(data, "Buffering", call)
1615

1716
n <- nrow(data)

R/checks.R

-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ check_v <- function(v,
5252
objects,
5353
allow_max_v = TRUE,
5454
call = rlang::caller_env()) {
55-
5655
if (is.null(v)) v <- Inf
5756

5857
if (!rlang::is_integerish(v) || length(v) != 1 || v < 1) {

R/spatial_block_cv.R

+10-9
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ spatial_block_cv <- function(data,
9595
original_number_of_blocks <- length(grid_blocks)
9696

9797
block_fun <- function(method) {
98-
switch(
99-
method,
98+
switch(method,
10099
"random" = random_block_cv(
101100
data,
102101
centroids,
@@ -152,13 +151,15 @@ spatial_block_cv <- function(data,
152151
split_objs$splits <- map(split_objs$splits, rm_out, buffer = buffer)
153152

154153
## Save some overall information
155-
cv_att <- list(v = v,
156-
method = method,
157-
relevant_only = relevant_only,
158-
radius = radius,
159-
buffer = buffer,
160-
repeats = repeats,
161-
...)
154+
cv_att <- list(
155+
v = v,
156+
method = method,
157+
relevant_only = relevant_only,
158+
radius = radius,
159+
buffer = buffer,
160+
repeats = repeats,
161+
...
162+
)
162163

163164
new_rset(
164165
splits = split_objs$splits,

R/spatial_clustering_cv.R

-1
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,3 @@ spatial_clustering_cv <- function(data,
135135
cv_att = cv_att
136136
)
137137
}
138-

R/spatial_vfold_cv.R

+17-18
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ spatial_buffer_vfold_cv <- function(data,
7070
breaks = 4,
7171
pool = 0.1,
7272
...) {
73-
7473
standard_checks(data, "`spatial_buffer_vfold_cv()`")
7574

7675
if (missing(radius) || missing(buffer)) {
@@ -115,15 +114,17 @@ spatial_buffer_vfold_cv <- function(data,
115114
}
116115

117116
if (!is.null(strata)) names(strata) <- NULL
118-
cv_att <- list(v = v,
119-
repeats = repeats,
120-
strata = strata,
121-
breaks = breaks,
122-
pool = pool,
123-
# Set radius and buffer to 0 if NULL or negative
124-
# This enables rsample::reshuffle_rset to work
125-
radius = max(c(radius, 0)),
126-
buffer = max(c(buffer, 0)))
117+
cv_att <- list(
118+
v = v,
119+
repeats = repeats,
120+
strata = strata,
121+
breaks = breaks,
122+
pool = pool,
123+
# Set radius and buffer to 0 if NULL or negative
124+
# This enables rsample::reshuffle_rset to work
125+
radius = max(c(radius, 0)),
126+
buffer = max(c(buffer, 0))
127+
)
127128

128129
if ("sf" %in% class(data)) {
129130
rset_class <- c("spatial_buffer_vfold_cv", "spatial_rset", "rset")
@@ -144,7 +145,6 @@ spatial_buffer_vfold_cv <- function(data,
144145
v = v,
145146
cv_att = cv_att
146147
)
147-
148148
}
149149

150150

@@ -158,7 +158,6 @@ spatial_leave_location_out_cv <- function(data,
158158
buffer = NULL,
159159
...,
160160
repeats = 1) {
161-
162161
if (!missing(group)) {
163162
group <- tidyselect::eval_select(rlang::enquo(group), data)
164163
}
@@ -188,10 +187,12 @@ spatial_leave_location_out_cv <- function(data,
188187
...
189188
)
190189

191-
cv_att <- list(v = v,
192-
group = group,
193-
radius = radius,
194-
buffer = buffer)
190+
cv_att <- list(
191+
v = v,
192+
group = group,
193+
radius = radius,
194+
buffer = buffer
195+
)
195196

196197
if ("sf" %in% class(data)) {
197198
rset_class <- c("spatial_leave_location_out_cv", "spatial_rset", "rset")
@@ -212,7 +213,6 @@ spatial_leave_location_out_cv <- function(data,
212213
v = v,
213214
cv_att = cv_att
214215
)
215-
216216
}
217217

218218
posthoc_buffer_rset <- function(data,
@@ -260,5 +260,4 @@ posthoc_buffer_rset <- function(data,
260260
attrib = cv_att,
261261
subclass = rset_class
262262
)
263-
264263
}

R/0_imports.R R/spatialsample-package.R

+10-6
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,20 @@
22
"_PACKAGE"
33

44
## usethis namespace: start
5+
#' @importFrom rsample complement
6+
#' @importFrom rsample new_rset
7+
#' @importFrom stats as.dist
8+
#' @importFrom stats cutree
9+
#' @importFrom stats hclust
10+
#' @importFrom stats kmeans
11+
#' @importFrom rsample make_splits
12+
#' @importFrom purrr map
13+
#' @importFrom rlang is_empty
14+
#' @importFrom dplyr dplyr_reconstruct
515
#' @useDynLib spatialsample, .registration = TRUE
616
## usethis namespace: end
717
NULL
818

9-
#' @importFrom rsample complement new_rset make_splits
10-
#' @importFrom purrr map
11-
#' @importFrom rlang is_empty
12-
#' @importFrom stats kmeans hclust cutree as.dist dist
13-
#' @importFrom dplyr dplyr_reconstruct
14-
#'
1519
#' @importFrom rsample analysis
1620
#' @export
1721
rsample::analysis

README.Rmd

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ output: github_document
66

77
```{r, include = FALSE}
88
knitr::opts_chunk$set(
9-
collapse = TRUE,
10-
comment = "#>",
11-
fig.path = "man/figures/README-",
12-
out.width = "100%"
9+
collapse = TRUE,
10+
comment = "#>",
11+
fig.path = "man/figures/README-",
12+
out.width = "100%"
1313
)
1414
library(ggplot2)
1515
theme_set(theme_minimal())

man/reexports.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/spatialsample-package.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/helper-rset.R

-1
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,3 @@ expect_s3_class_rset <- function(x) {
4646
expect_s3_class_bare_tibble <- function(x) {
4747
expect_s3_class(x, c("tbl_df", "tbl", "data.frame"), exact = TRUE)
4848
}
49-

tests/testthat/test-autoplot.R

-1
Original file line numberDiff line numberDiff line change
@@ -119,5 +119,4 @@ test_that("autoplot is stable", {
119119
"repeated LLO",
120120
autoplot(repeat_llo)
121121
)
122-
123122
})

tests/testthat/test-buffer.R

-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ chosen_points <- sf::st_as_sf(
66
)
77

88
test_that("buffering selects the expected points", {
9-
109
skip_if_offline()
1110
sf::sf_proj_network(enable = TRUE)
1211

@@ -160,7 +159,6 @@ test_that("buffering selects the expected points", {
160159
)
161160
)
162161
)
163-
164162
})
165163

166164
skip_if_not_installed("modeldata")
@@ -201,7 +199,6 @@ ames_sf <- sf::st_as_sf(
201199
)
202200

203201
test_that("using buffers", {
204-
205202
skip_if_not(sf::sf_use_s2())
206203
skip_if_offline()
207204
sf::sf_proj_network(enable = TRUE)
@@ -284,11 +281,9 @@ test_that("using buffers", {
284281
buffer = 500
285282
)
286283
)
287-
288284
})
289285

290286
test_that("buffers respect units", {
291-
292287
skip_if_not(sf::sf_use_s2())
293288
skip_if_offline()
294289
sf::sf_proj_network(enable = TRUE)
@@ -332,5 +327,4 @@ test_that("buffers respect units", {
332327
attr(rs2, "radius") <- 100
333328
attr(rs2, "buffer") <- 100
334329
expect_identical(rs1, rs2)
335-
336330
})

0 commit comments

Comments
 (0)