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

Warning about large number of cells only comes after cells are created #33

Open
mpjashby opened this issue Apr 2, 2023 · 2 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@mpjashby
Copy link
Owner

mpjashby commented Apr 2, 2023

Describe the bug
hotspot_grid() produces a warning if the created grid contains more than a certain number of cells, because this makes hotspot_kde() etc. very slow. But this warning is only triggered after the grid itself is created, which means that if creating the grid itself takes a long time then the user is left with a function that takes a long time to run and provides no feedback.

Expected behavior
The warning should be triggered before the grid is calculated, based on calculating approximately how many cells the grid will have once it's created. The warning should also be extended so that it provides some tips, e.g. If you are trying to calculate a grid for a very large area, consider using a larger `cell_size` or clip your data to a smaller area using `st_intersection()` .

@mpjashby mpjashby added the bug Something isn't working label Apr 2, 2023
@mpjashby mpjashby self-assigned this Apr 2, 2023
@mpjashby
Copy link
Owner Author

By default, warnings are only output after the function in which they're created has returned. In base R there is a way around this, but I can't find a way around it in rlang. I've created a question on Stack Overflow to see if there is a workaround or if I've missed something: https://stackoverflow.com/q/77123990/8222654

mpjashby added a commit that referenced this issue Sep 18, 2023
@mpjashby
Copy link
Owner Author

It seems that immediate warnings aren't possible in rlang and aren't going to become possible: r-lib/rlang#1546

The least-worst workaround seems to be to use rlang::inform() instead, since messages are outputted immediately: https://stackoverflow.com/a/77142044/8222654

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant