Skip to content

Commit fbf8c66

Browse files
Copilotkrlmlr
andauthored
feat: Use snake_case in arguments to _impl functions (#2462)
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: krlmlr <[email protected]> Co-authored-by: Kirill Müller <[email protected]> Co-authored-by: Kirill Müller <[email protected]>
1 parent 86d183b commit fbf8c66

File tree

24 files changed

+1274
-1171
lines changed

24 files changed

+1274
-1171
lines changed

R/aaa-auto.R

Lines changed: 607 additions & 607 deletions
Large diffs are not rendered by default.

R/assortativity.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ assortativity <- function(
215215
assortativity_impl(
216216
graph = graph,
217217
values = values,
218-
values.in = values.in,
218+
values_in = values.in,
219219
directed = directed,
220220
normalized = normalized
221221
)
@@ -230,7 +230,7 @@ assortativity_legacy <- function(
230230
assortativity_impl(
231231
graph = graph,
232232
values = types1,
233-
values.in = types2,
233+
values_in = types2,
234234
directed = directed
235235
)
236236
}

R/centralization.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ NULL
318318
centralize <- function(scores, theoretical.max = 0, normalized = TRUE) {
319319
centralization_impl(
320320
scores = scores,
321-
theoretical.max = theoretical.max,
321+
theoretical_max = theoretical.max,
322322
normalized = normalized
323323
)
324324
}

R/cliques.R

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,9 @@ weighted_cliques <- function(
428428
) {
429429
weighted_cliques_impl(
430430
graph = graph,
431-
vertex.weights = vertex.weights,
432-
min.weight = min.weight,
433-
max.weight = max.weight,
431+
vertex_weights = vertex.weights,
432+
min_weight = min.weight,
433+
max_weight = max.weight,
434434
maximal = maximal
435435
)
436436
}
@@ -440,7 +440,7 @@ weighted_cliques <- function(
440440
largest_weighted_cliques <- function(graph, vertex.weights = NULL) {
441441
largest_weighted_cliques_impl(
442442
graph = graph,
443-
vertex.weights = vertex.weights
443+
vertex_weights = vertex.weights
444444
)
445445
}
446446
#' @export
@@ -449,7 +449,7 @@ largest_weighted_cliques <- function(graph, vertex.weights = NULL) {
449449
weighted_clique_num <- function(graph, vertex.weights = NULL) {
450450
weighted_clique_number_impl(
451451
graph = graph,
452-
vertex.weights = vertex.weights
452+
vertex_weights = vertex.weights
453453
)
454454
}
455455

@@ -613,14 +613,14 @@ clique_size_counts <- function(graph, min = 0, max = 0, maximal = FALSE) {
613613
if (maximal) {
614614
maximal_cliques_hist_impl(
615615
graph = graph,
616-
min.size = min,
617-
max.size = max
616+
min_size = min,
617+
max_size = max
618618
)
619619
} else {
620620
clique_size_hist_impl(
621621
graph = graph,
622-
min.size = min,
623-
max.size = max
622+
min_size = min,
623+
max_size = max
624624
)
625625
}
626626
}

R/community.R

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,11 +1704,11 @@ cluster_leiden <- function(
17041704
res <- community_leiden_impl(
17051705
graph = graph,
17061706
weights = weights,
1707-
vertex.weights = vertex_weights,
1707+
vertex_weights = vertex_weights,
17081708
resolution = resolution,
17091709
beta = beta,
17101710
start = !is.null(membership),
1711-
n.iterations = n_iterations,
1711+
n_iterations = n_iterations,
17121712
membership = membership
17131713
)
17141714

@@ -1721,11 +1721,11 @@ cluster_leiden <- function(
17211721
res <- community_leiden_impl(
17221722
graph = graph,
17231723
weights = weights,
1724-
vertex.weights = vertex_weights,
1724+
vertex_weights = vertex_weights,
17251725
resolution = resolution,
17261726
beta = beta,
17271727
start = !is.null(membership),
1728-
n.iterations = 1,
1728+
n_iterations = 1,
17291729
membership = membership
17301730
)
17311731

@@ -2686,9 +2686,9 @@ cluster_infomap <- function(
26862686
) {
26872687
res <- community_infomap_impl(
26882688
graph = graph,
2689-
e.weights = e.weights,
2690-
v.weights = v.weights,
2691-
nb.trials = nb.trials
2689+
e_weights = e.weights,
2690+
v_weights = v.weights,
2691+
nb_trials = nb.trials
26922692
)
26932693

26942694
if (igraph_opt("add.vertex.names") && is_named(graph)) {
@@ -3228,7 +3228,7 @@ contract <- function(
32283228
contract_vertices_impl(
32293229
graph = graph,
32303230
mapping = mapping,
3231-
vertex.attr.comb = vertex.attr.comb
3231+
vertex_attr_comb = vertex.attr.comb
32323232
)
32333233
}
32343234

R/components.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -327,17 +327,15 @@ biconnected_components <- function(graph) {
327327
graph = graph
328328
)
329329

330-
# TODO: Clean up after fixing "." / "_" problem.
331-
# See https://github.com/igraph/rigraph/issues/1203
332-
333330
if (igraph_opt("return.vs.es")) {
334331
res$tree_edges <- lapply(
335332
res$tree_edges,
336333
unsafe_create_es,
337334
graph = graph,
338335
es = E(graph)
339336
)
340-
res$tree.edges <- NULL
337+
# Add backward-compatible dotted name
338+
res$tree.edges <- res$tree_edges
341339
}
342340

343341
if (igraph_opt("return.vs.es")) {
@@ -347,7 +345,8 @@ biconnected_components <- function(graph) {
347345
graph = graph,
348346
es = E(graph)
349347
)
350-
res$component.edges <- NULL
348+
# Add backward-compatible dotted name
349+
res$component.edges <- res$component_edges
351350
}
352351
if (igraph_opt("return.vs.es")) {
353352
res$components <- lapply(
@@ -359,7 +358,8 @@ biconnected_components <- function(graph) {
359358
}
360359
if (igraph_opt("return.vs.es")) {
361360
res$articulation_points <- create_vs(graph, res$articulation_points)
362-
res$articulation.points <- NULL
361+
# Add backward-compatible dotted name
362+
res$articulation.points <- res$articulation_points
363363
}
364364
res
365365
}

R/conversion.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ as_undirected <- function(
630630
res <- to_undirected_impl(
631631
graph = graph,
632632
mode = mode,
633-
edge.attr.comb = edge.attr.comb
633+
edge_attr_comb = edge.attr.comb
634634
)
635635

636636
res

R/cycles.R

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,7 @@ simple_cycles <- function(
100100
simple_cycles_impl(
101101
graph = graph,
102102
mode = mode,
103-
min.cycle.length = min %||%
104-
-1,
105-
max.cycle.length = max %||%
106-
-1
103+
min_cycle_length = min %||% -1,
104+
max_cycle_length = max %||% -1
107105
)
108106
}

R/degseq.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ is_graphical <- function(
146146
allowed.edge.types = c("simple", "loops", "multi", "all")
147147
) {
148148
is_graphical_impl(
149-
out.deg = out.deg,
150-
in.deg = in.deg,
151-
allowed.edge.types = allowed.edge.types
149+
out_deg = out.deg,
150+
in_deg = in.deg,
151+
allowed_edge_types = allowed.edge.types
152152
)
153153
}

R/games.R

Lines changed: 50 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2509,8 +2509,8 @@ sample_sbm <- function(
25092509
) {
25102510
sbm_game_impl(
25112511
n = n,
2512-
pref.matrix = pref.matrix,
2513-
block.sizes = block.sizes,
2512+
pref_matrix = pref.matrix,
2513+
block_sizes = block.sizes,
25142514
directed = directed,
25152515
loops = loops
25162516
)
@@ -2693,12 +2693,22 @@ dot_product <- function(...) constructor_spec(sample_dot_product, ...)
26932693
#' @export
26942694
#' @cdocs igraph_simple_interconnected_islands_game
26952695
sample_islands <- function(islands.n, islands.size, islands.pin, n.inter) {
2696-
simple_interconnected_islands_game_impl(
2697-
islands.n = islands.n,
2698-
islands.size = islands.size,
2699-
islands.pin = islands.pin,
2700-
n.inter = n.inter
2696+
res <- simple_interconnected_islands_game_impl(
2697+
islands_n = islands.n,
2698+
islands_size = islands.size,
2699+
islands_pin = islands.pin,
2700+
n_inter = n.inter
27012701
)
2702+
2703+
# Add backward-compatible dotted names
2704+
if (igraph_opt("add.params")) {
2705+
res$islands.n <- res$islands_n
2706+
res$islands.size <- res$islands_size
2707+
res$islands.pin <- res$islands_pin
2708+
res$n.inter <- res$n_inter
2709+
}
2710+
2711+
res
27022712
}
27032713

27042714

@@ -2745,7 +2755,7 @@ sample_k_regular <- function(
27452755
multiple = FALSE
27462756
) {
27472757
k_regular_game_impl(
2748-
no.of.nodes = no.of.nodes,
2758+
no_of_nodes = no.of.nodes,
27492759
k = k,
27502760
directed = directed,
27512761
multiple = multiple
@@ -2907,8 +2917,8 @@ sample_chung_lu <- function(
29072917
variant = c("original", "maxent", "nr")
29082918
) {
29092919
chung_lu_game_impl(
2910-
out.weights = out.weights,
2911-
in.weights = in.weights,
2920+
out_weights = out.weights,
2921+
in_weights = in.weights,
29122922
loops = loops,
29132923
variant = variant
29142924
)
@@ -3002,9 +3012,9 @@ sample_fitness <- function(
30023012
multiple = FALSE
30033013
) {
30043014
static_fitness_game_impl(
3005-
no.of.edges = no.of.edges,
3006-
fitness.out = fitness.out,
3007-
fitness.in = fitness.in,
3015+
no_of_edges = no.of.edges,
3016+
fitness_out = fitness.out,
3017+
fitness_in = fitness.in,
30083018
loops = loops,
30093019
multiple = multiple
30103020
)
@@ -3084,15 +3094,24 @@ sample_fitness_pl <- function(
30843094
multiple = FALSE,
30853095
finite.size.correction = TRUE
30863096
) {
3087-
static_power_law_game_impl(
3088-
no.of.nodes = no.of.nodes,
3089-
no.of.edges = no.of.edges,
3090-
exponent.out = exponent.out,
3091-
exponent.in = exponent.in,
3097+
res <- static_power_law_game_impl(
3098+
no_of_nodes = no.of.nodes,
3099+
no_of_edges = no.of.edges,
3100+
exponent_out = exponent.out,
3101+
exponent_in = exponent.in,
30923102
loops = loops,
30933103
multiple = multiple,
3094-
finite.size.correction = finite.size.correction
3104+
finite_size_correction = finite.size.correction
30953105
)
3106+
3107+
# Add backward-compatible dotted names
3108+
if (igraph_opt("add.params")) {
3109+
res$exponent.out <- res$exponent_out
3110+
res$exponent.in <- res$exponent_in
3111+
res$finite.size.correction <- res$finite_size_correction
3112+
}
3113+
3114+
res
30963115
}
30973116

30983117

@@ -3163,13 +3182,21 @@ sample_forestfire <- function(
31633182
ambs = 1,
31643183
directed = TRUE
31653184
) {
3166-
forest_fire_game_impl(
3185+
res <- forest_fire_game_impl(
31673186
nodes = nodes,
3168-
fw.prob = fw.prob,
3169-
bw.factor = bw.factor,
3187+
fw_prob = fw.prob,
3188+
bw_factor = bw.factor,
31703189
ambs = ambs,
31713190
directed = directed
31723191
)
3192+
3193+
# Add backward-compatible dotted names
3194+
if (igraph_opt("add.params")) {
3195+
res$fw.prob <- res$fw_prob
3196+
res$bw.factor <- res$bw_factor
3197+
}
3198+
3199+
res
31733200
}
31743201

31753202

@@ -3217,7 +3244,7 @@ sample_correlated_gnp <- function(
32173244
permutation = NULL
32183245
) {
32193246
correlated_game_impl(
3220-
old.graph = old.graph,
3247+
old_graph = old.graph,
32213248
corr = corr,
32223249
p = p,
32233250
permutation = permutation

0 commit comments

Comments
 (0)