Skip to content
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

refactor: use {lifecycle} for deprecation #1014

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

maelle
Copy link
Contributor

@maelle maelle commented Dec 18, 2023

Fix #697
Fix #977

@maelle maelle requested a review from krlmlr December 18, 2023 14:46
Copy link
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.

revdep/problems.md Show resolved Hide resolved
ℹ 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
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.

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
Contributor

Choose a reason for hiding this comment

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

🤷

revdep/problems.md Show resolved Hide resolved
revdep/problems.md Show resolved Hide resolved
> 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
Contributor

Choose a reason for hiding this comment

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

WAT

Copy link
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
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
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
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
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


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
Contributor

Choose a reason for hiding this comment

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

Okay

R/make.R Outdated
}

if (missing(simplify)) {
make_graph(edges = edges, n = n, isolates = isolates, directed = directed, ...)
Copy link
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
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
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
Contributor Author

maelle commented Jan 8, 2024

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

@maelle
Copy link
Contributor Author

maelle commented Jan 12, 2024

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

@maelle
Copy link
Contributor Author

maelle commented Jan 12, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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