Skip to content

Commit

Permalink
New Task*ST API, consolidate autoplot() (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
pat-s authored Jun 13, 2022
1 parent cd52eed commit aa5de5a
Show file tree
Hide file tree
Showing 165 changed files with 14,060 additions and 138,271 deletions.
4 changes: 1 addition & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ Imports:
data.table,
ggplot2,
mlr3misc (>= 0.9.2),
mlr3spatial (> 0.1.2),
paradox,
R6,
utils
Expand All @@ -44,6 +43,7 @@ Suggests:
mlr3pipelines,
mlr3tuning,
patchwork,
here,
plotly,
raster,
rgdal,
Expand All @@ -58,8 +58,6 @@ Suggests:
withr
VignetteBuilder:
knitr
Remotes:
mlr-org/mlr3spatial
Config/testthat/edition: 3
Config/testthat/parallel: true
Encoding: UTF-8
Expand Down
14 changes: 10 additions & 4 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Generated by roxygen2: do not edit by hand

S3method(as_task_classif,TaskClassifST)
S3method(as_task_classif_st,DataBackend)
S3method(as_task_classif_st,TaskClassifST)
S3method(as_task_classif_st,data.frame)
S3method(as_task_classif_st,sf)
S3method(as_task_regr,TaskRegrST)
S3method(as_task_regr_st,DataBackend)
S3method(as_task_regr_st,TaskClassifST)
S3method(as_task_regr_st,TaskRegrST)
S3method(as_task_regr_st,data.frame)
S3method(as_task_regr_st,sf)
Expand Down Expand Up @@ -63,16 +62,23 @@ export(ResamplingSptCVCluto)
export(ResamplingSptCVCstf)
export(TaskClassifST)
export(TaskRegrST)
export(as_task_classif.TaskClassifST)
export(as_task_classif_st)
export(as_task_classif_st.DataBackend)
export(as_task_classif_st.TaskClassifST)
export(as_task_classif_st.data.frame)
export(as_task_classif_st.sf)
export(as_task_regr_st)
export(as_task_regr_st.DataBackend)
export(as_task_regr_st.TaskClassifST)
export(as_task_regr_st.TaskRegrST)
export(as_task_regr_st.data.frame)
export(as_task_regr_st.sf)
export(autoplot)
import(checkmate)
import(data.table, except = transpose)
import(ggplot2)
import(mlr3)
import(mlr3misc)
import(mlr3spatial)
import(paradox)
importFrom(R6,R6Class)
importFrom(graphics,plot)
Expand Down
4 changes: 2 additions & 2 deletions R/ResamplingRepeatedSpCVBlock.R
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ ResamplingRepeatedSpCVBlock = R6Class("ResamplingRepeatedSpCVBlock",
}
instance = private$.sample(
task$row_ids,
get_coordinates(task),
get_crs(task)
task$coordinates(),
task$crs
)

self$instance = instance
Expand Down
2 changes: 1 addition & 1 deletion R/ResamplingRepeatedSpCVCoords.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ ResamplingRepeatedSpCVCoords = R6Class("ResamplingRepeatedSpCVCoords",
stopf("Grouping is not supported for spatial resampling methods.") # nocov
}

instance = private$.sample(task$row_ids, get_coordinates(task))
instance = private$.sample(task$row_ids, task$coordinates())

self$instance = instance
self$task_hash = task$hash
Expand Down
2 changes: 1 addition & 1 deletion R/ResamplingRepeatedSpCVDisc.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ ResamplingRepeatedSpCVDisc = R6Class("ResamplingRepeatedSpCVDisc",
function(x) private$.set_default_param_values(x)
)

private$.sample(task$row_ids, get_coordinates(task))
private$.sample(task$row_ids, task$coordinates())

self$task_hash = task$hash
self$task_nrow = task$nrow
Expand Down
2 changes: 1 addition & 1 deletion R/ResamplingRepeatedSpCVTiles.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ ResamplingRepeatedSpCVTiles = R6Class("ResamplingRepeatedSpCVTiles",
stopf("Grouping is not supported for spatial resampling methods")
}

private$.sample(task$row_ids, get_coordinates(task))
private$.sample(task$row_ids, task$coordinates())

self$task_hash = task$hash
self$task_nrow = task$nrow
Expand Down
4 changes: 2 additions & 2 deletions R/ResamplingRepeatedSptCVCluto.R
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ ResamplingRepeatedSptCVCluto = R6Class("ResamplingRepeatedSptCVCluto",
# time in seconds since 1/1/1970
time_num = as.numeric(time)

data_matrix = data.matrix(data.frame(get_coordinates(task), time_num))
data_matrix = data.matrix(data.frame(task$coordinates(), time_num))
colnames(data_matrix) = c("x", "y", "z")
} else {
data_matrix = data.matrix(data.frame(get_coordinates(task)))
data_matrix = data.matrix(data.frame(task$coordinates()))

colnames(data_matrix) = c("x", "y")
}
Expand Down
3 changes: 0 additions & 3 deletions R/ResamplingRepeatedSptCVCstf.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ ResamplingRepeatedSptCVCstf = R6Class("ResamplingRepeatedSptCVCstf",

#' @description
#' Create a "Spacetime Folds" resampling instance.
#'
#' For a list of available arguments, please see
#' [CAST::CreateSpacetimeFolds].
#' @param id `character(1)`\cr
#' Identifier for the resampling strategy.
initialize = function(id = "repeated_sptcv_cstf") {
Expand Down
4 changes: 2 additions & 2 deletions R/ResamplingSpCVBlock.R
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ ResamplingSpCVBlock = R6Class("ResamplingSpCVBlock",
}
instance = private$.sample(
task$row_ids,
get_coordinates(task),
get_crs(task)
task$coordinates(),
task$crs
)

self$instance = instance
Expand Down
6 changes: 3 additions & 3 deletions R/ResamplingSpCVBuffer.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ ResamplingSpCVBuffer = R6Class("ResamplingSpCVBuffer",
instance = private$.sample(
task$row_ids,
task$data()[[task$target_names]],
get_coordinates(task),
task$extra_args$positive,
get_crs(task),
task$coordinates(),
task$positive,
task$crs,
task$properties)

self$instance = instance
Expand Down
2 changes: 1 addition & 1 deletion R/ResamplingSpCVCoords.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ ResamplingSpCVCoords = R6Class("ResamplingSpCVCoords",
stopf("Grouping is not supported for spatial resampling methods")
}

instance = private$.sample(task$row_ids, get_coordinates(task))
instance = private$.sample(task$row_ids, task$coordinates())

self$instance = instance
self$task_hash = task$hash
Expand Down
2 changes: 1 addition & 1 deletion R/ResamplingSpCVDisc.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ ResamplingSpCVDisc = R6Class("ResamplingSpCVDisc",
stopf("Grouping is not supported for spatial resampling methods")
}

private$.sample(task$row_ids, get_coordinates(task))
private$.sample(task$row_ids, task$coordinates())

self$task_hash = task$hash
self$task_nrow = task$nrow
Expand Down
2 changes: 1 addition & 1 deletion R/ResamplingSpCVTiles.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ ResamplingSpCVTiles = R6Class("ResamplingSpCVTiles",
stopf("Grouping is not supported for spatial resampling methods")
}

private$.sample(task$row_ids, get_coordinates(task))
private$.sample(task$row_ids, task$coordinates())

self$task_hash = task$hash
self$task_nrow = task$nrow
Expand Down
4 changes: 2 additions & 2 deletions R/ResamplingSptCVCluto.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ ResamplingSptCVCluto = R6Class("ResamplingSptCVCluto",
# time in seconds since 1/1/1970
time_num = as.numeric(time)

data_matrix = data.matrix(data.frame(get_coordinates(task), time_num))
data_matrix = data.matrix(data.frame(task$coordinates(), time_num))
colnames(data_matrix) = c("x", "y", "z")
} else {
data_matrix = data.matrix(data.frame(get_coordinates(task)))
data_matrix = data.matrix(data.frame(task$coordinates()))

colnames(data_matrix) = c("x", "y")
}
Expand Down
3 changes: 0 additions & 3 deletions R/ResamplingSptCVCstf.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ ResamplingSptCVCstf = R6Class("ResamplingSptCVCstf",

#' @description
#' Create a "Spacetime Folds" resampling instance.
#'
#' For a list of available arguments, please see
#' [CAST::CreateSpacetimeFolds].
#' @param id `character(1)`\cr
#' Identifier for the resampling strategy.
initialize = function(id = "sptcv_cstf") {
Expand Down
Loading

0 comments on commit aa5de5a

Please sign in to comment.