Skip to content

Conversation

maelle
Copy link
Contributor

@maelle maelle commented Jul 22, 2025

Part of #731

@maelle maelle requested a review from schochastics July 22, 2025 14:50
@@ -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))
Copy link
Contributor Author

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.

Copy link
Contributor

@schochastics schochastics Jul 23, 2025

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

Copy link
Contributor Author

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.")
Copy link
Contributor Author

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.

@krlmlr
Copy link
Contributor

krlmlr commented Aug 21, 2025

Let's split this PR, the "Graph is unknown" thing is special and might become unnecessary with the new attribute handling, I hope.

@maelle
Copy link
Contributor Author

maelle commented Aug 27, 2025

Sorry, but split into what? One PR with all error messages minus the one I commented on?

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

Successfully merging this pull request may close these issues.

3 participants