Closed btupper closed 4 weeks ago
Hi @btupper , do make a pull request, please! It was on my list of todos to add 'stars' support, so very happy to look at it. Can you please make sure that your PR is against the 'dev' branch of 'tidysdm'? Many thanks!
Roger that!
Hmmm. Upon devtools::check()
I get the following. I haven't done anything with tests; it's beyond my ken.
> devtools::check()
══ Documenting ═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
ℹ Updating tidysdm documentation
ℹ Loading tidysdm
══ Building ════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
Setting env vars:
• CFLAGS : -Wall -pedantic -fdiagnostics-color=always
• CXXFLAGS : -Wall -pedantic -fdiagnostics-color=always
• CXX11FLAGS: -Wall -pedantic -fdiagnostics-color=always
• CXX14FLAGS: -Wall -pedantic -fdiagnostics-color=always
• CXX17FLAGS: -Wall -pedantic -fdiagnostics-color=always
• CXX20FLAGS: -Wall -pedantic -fdiagnostics-color=always
── R CMD build ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
✔ checking for file ‘/Users/ben/Library/CloudStorage/Dropbox/code/projects/tidysdm/DESCRIPTION’ (347ms)
─ preparing ‘tidysdm’: (583ms)
✔ checking DESCRIPTION meta-information ...
─ installing the package to build vignettes
✔ creating vignettes (3m 9.7s)
─ checking for LF line-endings in source and make files and shell scripts (765ms)
─ checking for empty or unneeded directories
─ building ‘tidysdm_0.9.6.9002.tar.gz’
══ Checking ════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
Setting env vars:
• _R_CHECK_CRAN_INCOMING_REMOTE_ : FALSE
• _R_CHECK_CRAN_INCOMING_ : FALSE
• _R_CHECK_FORCE_SUGGESTS_ : FALSE
• _R_CHECK_PACKAGES_USED_IGNORE_UNUSED_IMPORTS_: FALSE
• NOT_CRAN : true
── R CMD check ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
─ using log directory ‘/private/var/folders/gt/b3frwyjd7djdf8l4wvcxx7ww0000gp/T/RtmpvVOSsb/file114712d55708b/tidysdm.Rcheck’
─ using R version 4.4.1 (2024-06-14)
─ using platform: x86_64-apple-darwin20
─ R was compiled by
Apple clang version 14.0.0 (clang-1400.0.29.202)
GNU Fortran (GCC) 12.2.0
─ running under: macOS Sonoma 14.6.1
─ using session charset: UTF-8
─ using options ‘--no-manual --as-cran’
✔ checking for file ‘tidysdm/DESCRIPTION’
─ this is package ‘tidysdm’ version ‘0.9.6.9002’
─ package encoding: UTF-8
✔ checking package namespace information ...
N checking package dependencies (1.3s)
Imports includes 21 non-default packages.
Importing from so many packages makes the package vulnerable to any of
them becoming unavailable. Move as many as possible to Suggests and
use conditionally.
✔ checking if this is a source package
✔ checking if there is a namespace
✔ checking for executable files (1.6s)
✔ checking for hidden files and directories ...
✔ checking for portable file names ...
✔ checking for sufficient/correct file permissions
─ checking whether package ‘tidysdm’ can be installed ... [16s/16s] OK (16s)
✔ checking installed package size ...
✔ checking package directory ...
✔ checking for future file timestamps ...
✔ checking ‘build’ directory
✔ checking DESCRIPTION meta-information ...
✔ checking top-level files ...
✔ checking for left-over files
✔ checking index information (385ms)
✔ checking package subdirectories (918ms)
✔ checking code files for non-ASCII characters ...
✔ checking R files for syntax errors ...
✔ checking whether the package can be loaded (2.8s)
✔ checking whether the package can be loaded with stated dependencies (2.7s)
✔ checking whether the package can be unloaded cleanly (2.8s)
✔ checking whether the namespace can be loaded with stated dependencies (2.3s)
✔ checking whether the namespace can be unloaded cleanly (2.6s)
✔ checking whether startup messages can be suppressed (5.5s)
✔ checking dependencies in R code (5.8s)
✔ checking S3 generic/method consistency (2.6s)
✔ checking replacement functions (2.4s)
✔ checking foreign function calls (2.7s)
─ checking R code for possible problems ... [15s/15s] OK (15.4s)
✔ checking Rd files (560ms)
✔ checking Rd metadata ...
✔ checking Rd line widths ...
✔ checking Rd cross-references (339ms)
✔ checking for missing documentation entries (3.5s)
✔ checking for code/documentation mismatches (8.7s)
✔ checking Rd \usage sections (3.1s)
✔ checking Rd contents ...
✔ checking for unstated dependencies in examples ...
✔ checking contents of ‘data’ directory (3.1s)
✔ checking data for non-ASCII characters (3.2s)
✔ checking LazyData
✔ checking data for ASCII and uncompressed saves ...
✔ checking R/sysdata.rda ...
✔ checking installed files from ‘inst/doc’ ...
✔ checking files in ‘vignettes’ ...
─ checking examples ... [17s/17s] OK (17.2s)
─ checking examples with --run-donttest ... [26s/26s] OK (26s)
✔ checking for unstated dependencies in ‘tests’ ...
─ checking tests ...
✔ Running ‘spelling.R’
✔ Comparing ‘spelling.Rout’ to ‘spelling.Rout.save’ ...
Running the tests in ‘tests/testthat.R’ failed.
Last 13 lines of output:
Error in `filter_collinear.default("blah")`: no method available for class object type: character
Backtrace:
▆
1. ├─testthat::expect_error(filter_collinear("blah"), "no method available for this object type") at test_filter_collinear.R:35:3
2. │ └─testthat:::expect_condition_matching(...)
3. │ └─testthat:::quasi_capture(...)
4. │ ├─testthat (local) .capture(...)
5. │ │ └─base::withCallingHandlers(...)
6. │ └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
7. ├─tidysdm::filter_collinear("blah")
8. └─tidysdm:::filter_collinear.default("blah")
[ FAIL 1 | WARN 0 | SKIP 0 | PASS 267 ]
Error: Test failures
Execution halted
✔ checking for unstated dependencies in vignettes (561ms)
✔ checking package vignettes ...
─ checking re-building of vignette outputs ... [203s/194s] OK (3m 14.2s)
✔ checking for non-standard things in the check directory
✔ checking for detritus in the temp directory
See
‘/private/var/folders/gt/b3frwyjd7djdf8l4wvcxx7ww0000gp/T/RtmpvVOSsb/file114712d55708b/tidysdm.Rcheck/00check.log’
for details.
── R CMD check results ───────────────────────────────────────────────────────────────────────────────────────────────────────────────── tidysdm 0.9.6.9002 ────
Duration: 5m 56s
❯ checking tests ...
See below...
❯ checking package dependencies ... NOTE
Imports includes 21 non-default packages.
Importing from so many packages makes the package vulnerable to any of
them becoming unavailable. Move as many as possible to Suggests and
use conditionally.
── Test failures ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── testthat ────
> # This file is part of the standard setup for testthat.
> # It is recommended that you do not modify it.
> #
> # Where should you do additional test configuration?
> # Learn more about the roles of various files in:
> # * https://r-pkgs.org/tests.html
> # * https://testthat.r-lib.org/reference/test_package.html#special-files
>
> library(testthat)
> library(tidysdm)
Loading required package: tidymodels
── Attaching packages ────────────────────────────────────── tidymodels 1.2.0 ──
✔ broom 1.0.7 ✔ recipes 1.1.0
✔ dials 1.3.0 ✔ rsample 1.2.1
✔ dplyr 1.1.4 ✔ tibble 3.2.1
✔ ggplot2 3.5.1 ✔ tidyr 1.3.1
✔ infer 1.0.7 ✔ tune 1.2.1
✔ modeldata 1.4.0 ✔ workflows 1.1.4
✔ parsnip 1.2.1 ✔ workflowsets 1.1.0
✔ purrr 1.0.2 ✔ yardstick 1.3.1
── Conflicts ───────────────────────────────────────── tidymodels_conflicts() ──
✖ purrr::discard() masks scales::discard()
✖ dplyr::filter() masks stats::filter()
✖ purrr::is_null() masks testthat::is_null()
✖ dplyr::lag() masks stats::lag()
✖ tidyr::matches() masks rsample::matches(), dplyr::matches(), testthat::matches()
✖ recipes::step() masks stats::step()
• Learn how to get started at https://www.tidymodels.org/start/
Loading required package: spatialsample
>
> test_check("tidysdm")
Attaching package: 'plotrix'
The following object is masked from 'package:scales':
rescale
[ FAIL 1 | WARN 0 | SKIP 0 | PASS 267 ]
══ Failed tests ════════════════════════════════════════════════════════════════
── Error ('test_filter_collinear.R:35:3'): filter collinear variables with cor_caret ──
Error in `filter_collinear.default("blah")`: no method available for class object type: character
Backtrace:
▆
1. ├─testthat::expect_error(filter_collinear("blah"), "no method available for this object type") at test_filter_collinear.R:35:3
2. │ └─testthat:::expect_condition_matching(...)
3. │ └─testthat:::quasi_capture(...)
4. │ ├─testthat (local) .capture(...)
5. │ │ └─base::withCallingHandlers(...)
6. │ └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
7. ├─tidysdm::filter_collinear("blah")
8. └─tidysdm:::filter_collinear.default("blah")
[ FAIL 1 | WARN 0 | SKIP 0 | PASS 267 ]
Error: Test failures
Execution halted
1 error ✖ | 0 warnings ✔ | 1 note ✖
That's strange. I just rerun the continuous integration, and everything works fine. Can you try to pull the latest version of dev
and see whether that helps? It looks like you are getting the correct error, but somehow the error message is incorrectly parsed on your machine. I made a small change that might make the matching of text a bit more flexible.
It appears to generate a similar if not the same issue.
❯ R
R version 4.4.1 (2024-06-14) -- "Race for Your Life"
Copyright (C) 2024 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin20
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
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.
> devtools::check()
══ Documenting ═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
ℹ Updating tidysdm documentation
ℹ Loading tidysdm
Loading required package: tidymodels
── Attaching packages ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── tidymodels 1.2.0 ──
✔ broom 1.0.7 ✔ recipes 1.1.0
✔ dials 1.3.0 ✔ rsample 1.2.1
✔ dplyr 1.1.4 ✔ tibble 3.2.1
✔ ggplot2 3.5.1 ✔ tidyr 1.3.1
✔ infer 1.0.7 ✔ tune 1.2.1
✔ modeldata 1.4.0 ✔ workflows 1.1.4
✔ parsnip 1.2.1 ✔ workflowsets 1.1.0
✔ purrr 1.0.2 ✔ yardstick 1.3.1
── Conflicts ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── tidymodels_conflicts() ──
✖ purrr::discard() masks scales::discard()
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
✖ recipes::step() masks stats::step()
• Search for functions across packages at https://www.tidymodels.org/find/
Loading required package: spatialsample
══ Building ════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
Setting env vars:
• CFLAGS : -Wall -pedantic -fdiagnostics-color=always
• CXXFLAGS : -Wall -pedantic -fdiagnostics-color=always
• CXX11FLAGS: -Wall -pedantic -fdiagnostics-color=always
• CXX14FLAGS: -Wall -pedantic -fdiagnostics-color=always
• CXX17FLAGS: -Wall -pedantic -fdiagnostics-color=always
• CXX20FLAGS: -Wall -pedantic -fdiagnostics-color=always
── R CMD build ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
✔ checking for file ‘/Users/ben/Library/CloudStorage/Dropbox/code/projects/tidysdm/DESCRIPTION’ ...
─ preparing ‘tidysdm’: (638ms)
✔ checking DESCRIPTION meta-information ...
─ installing the package to build vignettes
✔ creating vignettes (3m 4.8s)
─ checking for LF line-endings in source and make files and shell scripts (851ms)
─ checking for empty or unneeded directories
─ building ‘tidysdm_0.9.6.9002.tar.gz’
══ Checking ════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
Setting env vars:
• _R_CHECK_CRAN_INCOMING_REMOTE_ : FALSE
• _R_CHECK_CRAN_INCOMING_ : FALSE
• _R_CHECK_FORCE_SUGGESTS_ : FALSE
• _R_CHECK_PACKAGES_USED_IGNORE_UNUSED_IMPORTS_: FALSE
• NOT_CRAN : true
── R CMD check ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
─ using log directory ‘/private/var/folders/gt/b3frwyjd7djdf8l4wvcxx7ww0000gp/T/RtmpyH4o4v/file4b487cecd253/tidysdm.Rcheck’
─ using R version 4.4.1 (2024-06-14)
─ using platform: x86_64-apple-darwin20
─ R was compiled by
Apple clang version 14.0.0 (clang-1400.0.29.202)
GNU Fortran (GCC) 12.2.0
─ running under: macOS Sonoma 14.6.1
─ using session charset: UTF-8
─ using options ‘--no-manual --as-cran’ (365ms)
✔ checking for file ‘tidysdm/DESCRIPTION’
─ this is package ‘tidysdm’ version ‘0.9.6.9002’
─ package encoding: UTF-8
✔ checking package namespace information ...
✔ checking package dependencies (2.8s)
✔ checking if this is a source package ...
✔ checking if there is a namespace
✔ checking for executable files (1.6s)
✔ checking for hidden files and directories ...
✔ checking for portable file names ...
✔ checking for sufficient/correct file permissions
─ checking whether package ‘tidysdm’ can be installed ... [15s/15s] OK (15.3s)
✔ checking installed package size ...
✔ checking package directory ...
✔ checking for future file timestamps ...
✔ checking ‘build’ directory
✔ checking DESCRIPTION meta-information ...
✔ checking top-level files ...
✔ checking for left-over files ...
✔ checking index information ...
✔ checking package subdirectories (786ms)
✔ checking code files for non-ASCII characters ...
✔ checking R files for syntax errors ...
✔ checking whether the package can be loaded (2.8s)
✔ checking whether the package can be loaded with stated dependencies (2.7s)
✔ checking whether the package can be unloaded cleanly (2.6s)
✔ checking whether the namespace can be loaded with stated dependencies (2.3s)
✔ checking whether the namespace can be unloaded cleanly (2.7s)
✔ checking whether startup messages can be suppressed (5.6s)
✔ checking dependencies in R code (6.3s)
✔ checking S3 generic/method consistency (2.7s)
✔ checking replacement functions (2.5s)
✔ checking foreign function calls (3s)
─ checking R code for possible problems ... [15s/16s] OK (15.6s)
✔ checking Rd files (606ms)
✔ checking Rd metadata ...
✔ checking Rd line widths ...
✔ checking Rd cross-references ...
✔ checking for missing documentation entries (3.1s)
✔ checking for code/documentation mismatches (8.4s)
✔ checking Rd \usage sections (3s)
✔ checking Rd contents ...
✔ checking for unstated dependencies in examples ...
✔ checking contents of ‘data’ directory (2.7s)
✔ checking data for non-ASCII characters (3s)
✔ checking LazyData
✔ checking data for ASCII and uncompressed saves ...
✔ checking R/sysdata.rda ...
✔ checking installed files from ‘inst/doc’ ...
✔ checking files in ‘vignettes’ ...
─ checking examples ... [16s/16s] OK (16.7s)
─ checking examples with --run-donttest ... [26s/27s] OK (27s)
✔ checking for unstated dependencies in ‘tests’ ...
─ checking tests ...
✔ Running ‘spelling.R’
✔ Comparing ‘spelling.Rout’ to ‘spelling.Rout.save’ ...
Running the tests in ‘tests/testthat.R’ failed.
Last 13 lines of output:
Error in `filter_collinear.default("blah")`: no method available for class object type: character
Backtrace:
▆
1. ├─testthat::expect_error(filter_collinear("blah"), "^no method available for this object type") at test_filter_collinear.R:35:3
2. │ └─testthat:::expect_condition_matching(...)
3. │ └─testthat:::quasi_capture(...)
4. │ ├─testthat (local) .capture(...)
5. │ │ └─base::withCallingHandlers(...)
6. │ └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
7. ├─tidysdm::filter_collinear("blah")
8. └─tidysdm:::filter_collinear.default("blah")
[ FAIL 1 | WARN 0 | SKIP 0 | PASS 267 ]
Error: Test failures
Execution halted
✔ checking for unstated dependencies in vignettes (612ms)
✔ checking package vignettes ...
─ checking re-building of vignette outputs ... [204s/194s] OK (3m 13.9s)
✔ checking for non-standard things in the check directory
✔ checking for detritus in the temp directory
See
‘/private/var/folders/gt/b3frwyjd7djdf8l4wvcxx7ww0000gp/T/RtmpyH4o4v/file4b487cecd253/tidysdm.Rcheck/00check.log’
for details.
── R CMD check results ───────────────────────────────────────────────────────────────────────────────────────────────────────────────── tidysdm 0.9.6.9002 ────
Duration: 5m 57s
❯ checking tests ...
See below...
── Test failures ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── testthat ────
> # This file is part of the standard setup for testthat.
> # It is recommended that you do not modify it.
> #
> # Where should you do additional test configuration?
> # Learn more about the roles of various files in:
> # * https://r-pkgs.org/tests.html
> # * https://testthat.r-lib.org/reference/test_package.html#special-files
>
> library(testthat)
> library(tidysdm)
Loading required package: tidymodels
── Attaching packages ────────────────────────────────────── tidymodels 1.2.0 ──
✔ broom 1.0.7 ✔ recipes 1.1.0
✔ dials 1.3.0 ✔ rsample 1.2.1
✔ dplyr 1.1.4 ✔ tibble 3.2.1
✔ ggplot2 3.5.1 ✔ tidyr 1.3.1
✔ infer 1.0.7 ✔ tune 1.2.1
✔ modeldata 1.4.0 ✔ workflows 1.1.4
✔ parsnip 1.2.1 ✔ workflowsets 1.1.0
✔ purrr 1.0.2 ✔ yardstick 1.3.1
── Conflicts ───────────────────────────────────────── tidymodels_conflicts() ──
✖ purrr::discard() masks scales::discard()
✖ dplyr::filter() masks stats::filter()
✖ purrr::is_null() masks testthat::is_null()
✖ dplyr::lag() masks stats::lag()
✖ tidyr::matches() masks rsample::matches(), dplyr::matches(), testthat::matches()
✖ recipes::step() masks stats::step()
• Learn how to get started at https://www.tidymodels.org/start/
Loading required package: spatialsample
>
> test_check("tidysdm")
Attaching package: 'plotrix'
The following object is masked from 'package:scales':
rescale
[ FAIL 1 | WARN 0 | SKIP 0 | PASS 267 ]
══ Failed tests ════════════════════════════════════════════════════════════════
── Error ('test_filter_collinear.R:35:3'): filter collinear variables with cor_caret ──
Error in `filter_collinear.default("blah")`: no method available for class object type: character
Backtrace:
▆
1. ├─testthat::expect_error(filter_collinear("blah"), "^no method available for this object type") at test_filter_collinear.R:35:3
2. │ └─testthat:::expect_condition_matching(...)
3. │ └─testthat:::quasi_capture(...)
4. │ ├─testthat (local) .capture(...)
5. │ │ └─base::withCallingHandlers(...)
6. │ └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
7. ├─tidysdm::filter_collinear("blah")
8. └─tidysdm:::filter_collinear.default("blah")
[ FAIL 1 | WARN 0 | SKIP 0 | PASS 267 ]
Error: Test failures
Execution halted
1 error ✖ | 0 warnings ✔ | 0 notes ✔
Aha! I found the culprit - an issue of my own making. I slightly more verbose error message from filter_collinear()
when I was debugging and then forgot to change it back before committing. I'm sorry about that red herring.
@btupper That error is still present in the PR, can you please upload the fix?
Well, that's an odd thing. Rstudio's 'git' tab showed nothing needed to be done, but command line git said I still needed to push (which I just did). I have not encountered that kind of a disconnect before. The issue seems to resolved now.
Thank you @btupper , this is now merged into dev
, with appropriate recognition, in ff8d4829b7dac0a4e97da1eb203726f86142c8f1. Do let me know when your sunfish example is finished, and we'll add a link from the tidysdm
website.
I am so pleased to have found
tidysdm
! As I started to work through the vignettes, it occurred to me that there are number of us in our group who mostly work with thesf
/stars
tools rather than theterra
tools. I started to explore the underlying functions, and realized that with small modifications it would be easy to maketidysdm
work seamlessly with eitherSpatRaster
orstars
classes. There seemed to be just two types of modifications needed - each pretty minor. The "deeper" computations and data handling remain as you have already coded them usingterra
.Class dispatch
It was easy to add class methods for
stars
where the the input is cast fromstars
toSpatRaster
and then theSpatRaster
method is invoked.Simple casting
For other approach (where class dispatch is not involved) it was easy to simply test the class of the input and cast as needed.
An example I have modified a copy of your overview vignette as a demonstration.
The authors of
terra
andsf/stars
have set a nice precedence for interoperability. This seems like a perfect chance to leverage that. If it doesn't feel like a good fit (which I can understand) I won't pester you with a pull request.Cheers, Ben