-
-
Notifications
You must be signed in to change notification settings - Fork 207
chore: improve errors in iterators.R #2006
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
base: main
Are you sure you want to change the base?
Conversation
@@ -1144,14 +1144,11 @@ simple_es_index <- function(x, i, na_ok = FALSE) { | |||
#' @name igraph-vs-attributes | |||
#' @export | |||
`[[<-.igraph.vs` <- function(x, i, value) { | |||
if ( | |||
!"name" %in% names(attributes(value)) || | |||
!"value" %in% names(attributes(value)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand how value could be missing. I've added tests for when name is missing, but value missing would mean nothing on the right side of the arrow?! Am I missing something obvious?
In any case we need to improve the mysterious "Invalid indexing" error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With main:
g <- make_ring(10)
V(g)[10][["name"]] <- "z"
#> Error in `[[<-.igraph.vs`(`*tmp*`, "name", value = "z"): invalid indexing
V(g)[["name"]] <- letters[1:10]
#> Error in `[[<-.igraph.vs`(`*tmp*`, "name", value = c("a", "b", "c", "d", : invalid indexing
With stoop2 branch
g <- make_ring(10)
V(g)[10][["name"]] <- "z"
#> Error in `[[<-`:
#> ! Can't find "name" for attribute.
V(g)[["name"]] <- letters[1:10]
#> Error in `[[<-`:
#> ! Can't find "name" for attribute.
Created on 2025-07-23 with reprex v2.1.1
Not sure this helps with your question because this function confuses me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you were able to get this error, no name, but no value makes 0 sense to me. I find the message "invalid indexing" extremely confusing.
} | ||
if (is.null(get_es_graph(x))) { | ||
stop("Graph is unknown.") | ||
cli::cli_abort("Can't find graph.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder whether we could improve this.
Let's split this PR, the "Graph is unknown" thing is special and might become unnecessary with the new attribute handling, I hope. |
Sorry, but split into what? One PR with all error messages minus the one I commented on? |
Part of #731