Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show top-level function in error message #156

Merged
merged 1 commit into from
Nov 14, 2023
Merged

Conversation

mikemahoney218
Copy link
Member

Current HEAD:

library(spatialsample)
drought_sf <- sf::st_as_sf(
  expand.grid(
    x = seq(995494, 1018714, 430),
    y = seq(1019422, by = 430, length.out = 55)
  ),
  coords = c("x", "y"),
  crs = 7760
)
spatial_block_cv(drought_sf, expand_bbox = 0)
#> Error in `generate_folds_from_blocks()` at spatialsample/R/spatial_block_cv.R:204:2:
#> ! Some observations fell exactly on block boundaries, meaning they were assigned to multiple assessment sets unexpectedly.
#> ℹ Try setting a different `expand_bbox` value, an `offset`, or use a different number of folds.
#> Backtrace:
#>     ▆
#>  1. └─spatialsample::spatial_block_cv(drought_sf, expand_bbox = 0)
#>  2.   └─spatialsample (local) block_fun(method) at spatialsample/R/spatial_block_cv.R:129:4
#>  3.     └─spatialsample:::random_block_cv(...) at spatialsample/R/spatial_block_cv.R:106:4
#>  4.       └─spatialsample:::generate_folds_from_blocks(data, centroids, grid_blocks, v, n, radius, buffer) at spatialsample/R/spatial_block_cv.R:204:2
#>  5.         └─rlang::abort(...) at spatialsample/R/spatial_block_cv.R:264:4

Created on 2023-11-14 with reprex v2.0.2

This PR:

library(spatialsample)
drought_sf <- sf::st_as_sf(
  expand.grid(
    x = seq(995494, 1018714, 430),
    y = seq(1019422, by = 430, length.out = 55)
  ),
  coords = c("x", "y"),
  crs = 7760
)
spatial_block_cv(drought_sf, expand_bbox = 0)
#> Error in `spatial_block_cv()`:
#> ! Some observations fell exactly on block boundaries, meaning they were assigned to multiple assessment sets unexpectedly.
#> ℹ Try setting a different `expand_bbox` value, an `offset`, or use a different number of folds.
#> Backtrace:
#>     ▆
#>  1. └─spatialsample::spatial_block_cv(drought_sf, expand_bbox = 0)
#>  2.   └─spatialsample (local) block_fun(method) at spatialsample/R/spatial_block_cv.R:129:4
#>  3.     └─spatialsample:::random_block_cv(...) at spatialsample/R/spatial_block_cv.R:106:4
#>  4.       └─spatialsample:::generate_folds_from_blocks(...) at spatialsample/R/spatial_block_cv.R:205:2
#>  5.         └─rlang::abort(...) at spatialsample/R/spatial_block_cv.R:265:4

Created on 2023-11-14 with reprex v2.0.2

@mikemahoney218
Copy link
Member Author

I was surprised this didn't need a snapshot to be updated, but apparently one of the differences in expect_snapshot_error() vs expect_snapshot(error = TRUE) is that the snapshot no longer includes this part of the error message:

# duplicated observations in assessment sets throws an error
Some observations fell exactly on block boundaries, meaning they were assigned to multiple assessment sets unexpectedly.
i Try setting a different `expand_bbox` value, an `offset`, or use a different number of folds.

@mikemahoney218 mikemahoney218 merged commit 9877514 into main Nov 14, 2023
12 of 13 checks passed
@mikemahoney218 mikemahoney218 deleted the error_message branch November 14, 2023 15:31
Copy link

This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant