-
-
Notifications
You must be signed in to change notification settings - Fork 200
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
Unintended type conversions when using disjoint_union
#761
Comments
Tracing shows that this line is to blame in the source of
Shorter repro using attr <- list()
attr$date <- c(attr$date, as.POSIXct("2021-01-01 01:01:01"))
attr$date
#> [1] 1609459261 Created on 2023-04-07 with reprex v2.0.2 |
I'm not fluent enough in R to decide what's the best way to deal with this so I'm leaving this up to @krlmlr |
Minimal reprex of the original problem: options(conflicts.policy = list(warn = FALSE))
library(igraph)
# create two graphs
g1 <- make_graph(~ A - -B)
g2 <- make_graph(~ D - -E)
# add an edge attribute of class POSIXct to each graph
g1 <- set.edge.attribute(g1, "date", value = as.POSIXct(c("2021-01-01 01:01:01")))
g2 <- set.edge.attribute(g2, "date", value = as.POSIXct(c("2021-03-03 03:03:03")))
# create the union of the two graphs
u <- disjoint_union(g1, g2)
E(u)$date
#> [1] 1609459261 1614736983 Created on 2023-05-20 with reprex v2.0.2 |
Feel free to add |
Are there any news on this issue? |
Thanks. We will prioritize issues next week. |
Excuse me for asking again; several weeks have passed since the last comment. Can you estimate approximately when you will be able to fix this bug? |
For your information: I checked this issue again, as I reported it when using igraph 1.4.0. |
We're now in a state where we can start tackling bugs like this. I can't give a timeline, though. @maelle: I think using |
Vignette section: https://vctrs.r-lib.org/articles/stability.html#c-and-vctrsvec_c . Also useful: the rest of that vignette and https://vctrs.r-lib.org/articles/type-size.html . |
Bug Description
With the breaking change of igraph version 1.4.0, igraph now respects the concrete type of attributes when setting edge or vertex attributes (#633). While I am happy that the type is respect now, the function
disjoint_union
does not respect the attributes' types and does some weird type conversions.How to Reproduce this Bug
Here is a minimum working example, in which the wrong behavior of
disjoint_union
can be seen:You can find the corresponding output of the
str(...)
calls below – look for thedate
attribute in each of the three graphs to see thatdisjoint_union
performs an unwanted type conversion: Forg1
andg2
, the class of thedate
attribute isPOSIXct
. However, foru
, the class of thedate
attribute isnum
. This leads to various problems if you assume in your code that the dates are always given inPOSIXct
but thendisjoint_union
inadvertently converts them into numeric unix timestamps.Version Information
Rest of the output of
sessionInfo()
:@hechtlC: FYI
The text was updated successfully, but these errors were encountered: