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

Adopt a more explicit error message when running edge_length (and related function) with active nodes #216

Closed
agila5 opened this issue Jun 27, 2022 · 1 comment

Comments

@agila5
Copy link
Collaborator

agila5 commented Jun 27, 2022

Describe the bug
I think the error when running edge_length with active nodes could be more explicit. For example, we could copy the same workflow as in tidygraph.

Reproducible example

library(sfnetworks)
library(tidygraph)
#> 
#> Attaching package: 'tidygraph'
#> The following object is masked from 'package:stats':
#> 
#>     filter
sfn <- as_sfnetwork(roxel)
# Unclear error
sfn %>% 
  arrange(edge_length())
#> Error in `st_as_sf()`:
#> ! Problem with the implicit `transmute()` step.
#> ✖ Problem while computing `..1 = edge_length()`.
#> ✖ `..1` must be size 701 or 1, not 851.

# Better explanation
sfn %>% 
  filter(edge_is_loop())
#> Error in `stopifnot()`:
#> ! Problem while computing `..1 = edge_is_loop()`.
#> Caused by error in `expect_edges()`:
#> ! This call requires edges to be active

Created on 2022-06-27 by the reprex package (v2.0.1)

Expected behavior
A better error message

R Session Info
(Will add later)

@agila5 agila5 changed the title Adopt a more explicit error message when running edge_length with active nodes Adopt a more explicit error message when running edge_length (and related function) with active nodes Jun 27, 2022
@luukvdmeer
Copy link
Owner

Implemented in v0.6.0. The message is now:

This call requires edges to be active

Just as in tidygraph. Similar error message is printed for the node_* functions when nodes are not active.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants