feat: Add attribute combination support to graph operators#2676
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
There was a problem hiding this comment.
Why not
Can't use rename with this function (not naming it)
Hint: rename is only supported by blablabla
…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).
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:
|
…eparate PR Per review feedback (PR #2676), the snake_case renaming of the igraph options and of the *.attr.comb function arguments (with soft-deprecation of the dotted names) is "par" code that will be reviewed in its own PR. The full renaming work is preserved on branch `par-attr-comb-options`. This reverts the renaming here, keeping the original dotted option names: - R/par.R: restore dotted `vertex.attr.comb` / `edge.attr.comb` options and drop the alias/soft-deprecation machinery. Keep the feature's new `graph.attr.comb` option (dotted), defaulting to "rename". - simplify() / as_undirected() / contract(): drop the argument-migration blocks; keep the dotted `edge.attr.comb` / `vertex.attr.comb` arguments (community.R, conversion.R, simple.R, aaa-*.R, migrations.R, types-RR.yaml, and the associated tests/snapshots revert to main). - union() / intersection() / compose() / disjoint_union(): the new attribute-combination arguments use dotted names (graph.attr.comb / vertex.attr.comb / edge.attr.comb). Also addresses review comment r3473306646: use `...length() == 0` instead of `nargs() == 0` in igraph_i_options(). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… names Split out from #2676 per review feedback: the renaming of the igraph options and the *.attr.comb function arguments (with soft-deprecation of the dotted names) is carried here so it can be reviewed on its own. - igraph options vertex.attr.comb / edge.attr.comb (and the new graph.attr.comb) are renamed to snake_case *_combine, with back-compatible aliasing in igraph_opt() / igraph_options(); the dotted keys still read and set, soft-deprecated (R/par.R). - simplify() / as_undirected() / contract() gain snake_case edge_attr_combine / vertex_attr_combine arguments via the argument-migration infrastructure (tools/migrations.R); dotted names keep working and soft-deprecate. - union() / intersection() / compose() / disjoint_union() use the snake_case *_combine argument names. - Updates stimulus codegen defaults (types-RR.yaml), regenerated *_impl defaults, and the affected tests/snapshots. Retains the igraph_i_options() ...length() fix from the base branch. 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 a190d59 is merged into main:
|
… names Split out from #2676 per review feedback: the renaming of the igraph options and the *.attr.comb function arguments (with soft-deprecation of the dotted names) is carried here so it can be reviewed on its own. - igraph options vertex.attr.comb / edge.attr.comb (and the new graph.attr.comb) are renamed to snake_case *_combine, with back-compatible aliasing in igraph_opt() / igraph_options(); the dotted keys still read and set, soft-deprecated (R/par.R). - simplify() / as_undirected() / contract() gain snake_case edge_attr_combine / vertex_attr_combine arguments via the argument-migration infrastructure (tools/migrations.R); dotted names keep working and soft-deprecate. - union() / intersection() / compose() / disjoint_union() use the snake_case *_combine argument names. - Updates stimulus codegen defaults (types-RR.yaml), regenerated *_impl defaults, and the affected tests/snapshots. Retains the igraph_i_options() ...length() fix from the base branch. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
fix #57