Skip to content

refactor: use {lifecycle} for deprecation#1014

Closed
maelle wants to merge 5 commits intoigraph:mainfrom
maelle:zzz-december
Closed

refactor: use {lifecycle} for deprecation#1014
maelle wants to merge 5 commits intoigraph:mainfrom
maelle:zzz-december

Conversation

@maelle
Copy link
Copy Markdown
Contributor

@maelle maelle commented Dec 18, 2023

Fix #697
Fix #977

@maelle maelle requested a review from krlmlr December 18, 2023 14:46
@aviator-app
Copy link
Copy Markdown
Contributor

aviator-app Bot commented Dec 18, 2023

Current Aviator status

Aviator will automatically update this comment as the status of the PR changes.
Comment /aviator refresh to force Aviator to re-examine your PR (or learn about other /aviator commands).

This pull request is currently open (not queued).

How to merge

To merge this PR, comment /aviator merge or add the mergequeue label.


See the real-time status of this PR on the Aviator webapp.

Use the Aviator Chrome Extension to see the status of your PR within GitHub.

Comment thread revdep/problems.md
Comment thread revdep/problems.md
ℹ Please use `set_edge_attr()` instead.
> causal.effect("y", "x", G = g)
Error in simple_es_index(x, ii) : Unknown edge selected
Calls: causal.effect ... [ -> [.igraph.es -> lapply -> FUN -> simple_es_index
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea why this is failing now.

Comment thread revdep/problems.md
3. │ └─rlang::eval_bare(expr, quo_get_env(quo))
4. └─cfid::import_graph(ig)
5. └─cfid::dag(paste0(c(g_obs, g_unobs), collapse = "; "))
6. └─cfid:::stopifnot_(nzchar(x), "Argument `x` contains only whitespace or special characters.")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷

Comment thread revdep/problems.md
Comment thread revdep/problems.md
Comment thread revdep/problems.md
> q.arg = list(list(min=-pi, max=pi), list(min=-pi, max=pi), list(min=-pi, max=pi))
> estimateGraph(f.mat=ishigami.fun, d=3, q.arg=q.arg, n.tot=10000, method="LiuOwen")
Error in (function (edges, n = max(edges), directed = TRUE) :
unused arguments (3, FALSE)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WAT

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again related to how we pass the ... 👀

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now I'm wondering whether there are uncaught occurrences of the same issue for other deprecated functions, I'll check.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

although, in this case, I'm starting to think the error is one usage error that existed before but wasn't caught.

The code is graph(as.vector(t(E)), d , FALSE) where d is 3 and as.vector(t(E)) is c(1, 3). In make_graph(), the ... are for "when the graph is given via a literal". Here the edges are numeric. So we're in

rigraph/R/make.R

Lines 612 to 627 in b806ec2

old_graph <- function(edges, n = max(edges), directed = TRUE) {
on.exit(.Call(R_igraph_finalizer))
if (missing(n) && (is.null(edges) || length(edges) == 0)) {
n <- 0
}
.Call(
R_igraph_create, as.numeric(edges) - 1, as.numeric(n),
as.logical(directed)
)
}
args <- list(edges, ...)
if (!missing(n)) args <- c(args, list(n = n))
if (!missing(directed)) args <- c(args, list(directed = directed))
do.call(old_graph, args)
where the ... are actually not used since the old_graph() function doesn't have more arguments.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

although, why did it used to work

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

igraph::make_graph(c(1, 3), 3, FALSE)
#> IGRAPH 628f020 U--- 3 1 -- 
#> + edge from 628f020:
#> [1] 1--3
igraph::graph(c(1, 3), 3, FALSE)
#> Warning: `graph()` was deprecated in igraph 2.0.0.
#> ℹ Please use `make_graph()` instead.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.
#> Error in (function (edges, n = max(edges), directed = TRUE) : unused arguments (3, FALSE)

Created on 2024-01-08 with reprex v2.0.2

Comment thread revdep/problems.md

Quitting from lines 46-56 [unnamed-chunk-5] (Tutorial.Rmd)
Error: processing vignette 'Tutorial.Rmd' failed with diagnostics:
At vendor/cigraph/src/graph/type_indexededgelist.c:101 : Number of vertices must not be negative. Invalid value
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay

Comment thread R/make.R Outdated
}

if (missing(simplify)) {
make_graph(edges = edges, n = n, isolates = isolates, directed = directed, ...)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this fail if edges is a formula?

I don't like the interface of make_graph(), but deprecating it is an uphill battle. Can we instead export all relevant functions (e.g., make_famous_graph()), and supersede it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's open another issue regarding make_graph()'s superseding, and I'll do my best to fix the current graph() here in this PR.

@maelle
Copy link
Copy Markdown
Contributor Author

maelle commented Jan 8, 2024

I wonder how, in the problematic cases, we could "replay" the call exactly, just switching the function name. https://rlang.r-lib.org/reference/stack.html

@maelle
Copy link
Copy Markdown
Contributor Author

maelle commented Jan 8, 2024

I'll come back to this later (this week or next), still some thinking needed.

@maelle maelle mentioned this pull request Jan 12, 2024
@maelle
Copy link
Copy Markdown
Contributor Author

maelle commented Jan 12, 2024

@krlmlr we could discuss the approach in b33124c (#1014)

@maelle
Copy link
Copy Markdown
Contributor Author

maelle commented Jan 12, 2024

The functions needing a similar fix are graph() but also graph.famous() and graph.formula(). 🤔

@krlmlr krlmlr marked this pull request as draft April 9, 2024 13:43
@krlmlr krlmlr assigned krlmlr and maelle and unassigned krlmlr Apr 9, 2024
@maelle maelle mentioned this pull request Jun 4, 2024
@aviator-app aviator-app Bot closed this in #1390 Jun 6, 2024
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jun 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

graph()/make_graph() error in rev deps Use {lifecycle} instead of zzz-deprecate.R

2 participants