feat: Add attribute combination support to graph operators#2676
feat: Add attribute combination support to graph operators#2676schochastics wants to merge 22 commits into
Conversation
…tion, compose, disjoint_union)
|
devtools::document() doesnt work locally for me |
|
This is how benchmark results would change (along with a 95% confidence interval in relative change) if c26ab02 is merged into main:
|
…lper Address review feedback on #2676: - Rename the new graph.attr.comb/vertex.attr.comb/edge.attr.comb arguments of union()/intersection()/compose()/disjoint_union() to snake_case (these args are new in this PR, so no deprecation is needed). - Extract rename_attr_if_needed() back out of combine.attrs() for the "rename" strategy, preserving the historical overwrite-on-clash semantics under chains of %du%. - Add a clarifying comment on the backward-compatible "rename" default. - Move the make_named_pair() test helper into helper.R. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…tted names Follow-up to review feedback on #2676 ("clean up edge.attr.comb"): - simplify(), as_undirected() and contract() gain snake_case edge_attr_comb / vertex_attr_comb arguments via the argument-migration infrastructure (tools/migrations.R). The old dotted names still work and emit a single lifecycle::deprecate_soft() warning. - Rename the matching igraph option keys edge.attr.comb -> edge_attr_comb and vertex.attr.comb -> vertex_attr_comb, with back-compatible aliasing in igraph_opt()/igraph_options(); the dotted keys still read and set, soft- deprecated. Update the stimulus codegen default (types-RR.yaml) and the regenerated *_impl defaults to match. Deprecated wrappers (as.undirected(), contract.vertices()) are left frozen; their snapshot now records the resulting layered deprecation warnings. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
This is how benchmark results would change (along with a 95% confidence interval in relative change) if b58da44 is merged into main:
|
…e combination in operators
The `graph_attr_comb` parameter in `union()`, `intersection()`, `disjoint_union()`, and `compose()` now defaults to `igraph_opt("graph_attr_comb")` (which is `"rename"` by default) instead of a hard-coded `"rename"`. This allows users to globally configure graph attribute combination behavior via `igraph_options()`.
|
This is how benchmark results would change (along with a 95% confidence interval in relative change) if 6d94668 is merged into main:
|
|
@maelle it is now |
|
This is how benchmark results would change (along with a 95% confidence interval in relative change) if a85a78c is merged into main:
|
|
Yay 🎉 |
| if (is.na(x)) { | ||
| idx <- pmatch(tolower(x), known_names) | ||
| if (is.na(idx)) { | ||
| if (!allow_rename && identical(tolower(x), "rename")) { |
There was a problem hiding this comment.
It'd be more logical to me to invert the two
if (identical(tolower(x), "rename") && !allow_rename) {There was a problem hiding this comment.
you seem to hold a grudge against identical() 😛
Just very defensive type-strict scalar comparison. Probably == would work here but its igraph, so better be save 😉
| if (is.na(idx)) { | ||
| if (!allow_rename && identical(tolower(x), "rename")) { | ||
| cli::cli_abort( | ||
| "{.val rename} is only supported by graph operators ({.fn union}, {.fn intersection}, {.fn compose}, {.fn disjoint_union}), not by this function." |
There was a problem hiding this comment.
Rephrase to
- Can't use rename with function X (possible to add its name)
- Hint: rename is only supported by blablabla
There was a problem hiding this comment.
This gets surprisingly complicated so I would opt out of that and keep it as is
|
|
||
| test_that("union() picks first non-NA when only one input has the attr", { | ||
| gs <- make_named_pair() | ||
| u <- union(gs$g1, gs$g2, vertex_attr_combine = "first", byname = TRUE) |
There was a problem hiding this comment.
why byname and not by_name?
There was a problem hiding this comment.
because the argument was alwas defined as byname
…n igraph.i.attribute.combination
… before checking allow_rename flag
|
This is how benchmark results would change (along with a 95% confidence interval in relative change) if fbf2bcc is merged into main:
|
krlmlr
left a comment
There was a problem hiding this comment.
I'd like to review of the "par" code in a separate PR. Let's keep the original option names dotted in this PR (revert as a single commit).
| } | ||
|
|
||
| igraph_i_options <- function(..., .in = parent.frame()) { | ||
| if (nargs() == 0) { |
There was a problem hiding this comment.
| if (...length() == 0) { |
|
This is how benchmark results would change (along with a 95% confidence interval in relative change) if a8987c4 is merged into main:
|
fix #57