From 2e6b3d02be0efa8b070b83e3f951b92fbb6bf61a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Tue, 6 Jan 2026 12:46:30 +0100 Subject: [PATCH] feat: improve formatting of error messages from C --- src/rinterface_extra.c | 23 ++- tests/testthat/_snaps/aaa-auto.md | 213 ++++++++++++++++++---------- tests/testthat/_snaps/centrality.md | 3 +- tests/testthat/_snaps/games.md | 6 +- tests/testthat/test-centrality.R | 10 +- 5 files changed, 174 insertions(+), 81 deletions(-) diff --git a/src/rinterface_extra.c b/src/rinterface_extra.c index ca1dc00f642..4ac8b903e47 100644 --- a/src/rinterface_extra.c +++ b/src/rinterface_extra.c @@ -2315,6 +2315,17 @@ static inline const char* maybe_add_punctuation(const char* msg, const char* pun return is_punctuated(msg) ? "" : punctuation; } +/* Strip vendor/cigraph/src/ prefix from file path */ +static inline const char* simplify_file_path(const char* file) { + const char* prefix = "vendor/cigraph/src/"; + size_t prefix_len = strlen(prefix); + + if (strncmp(file, prefix, prefix_len) == 0) { + return file + prefix_len; + } + return file; +} + void Rx_igraph_fatal_handler(const char *reason, const char *file, int line) { #ifdef IGRAPH_SANITIZER_AVAILABLE __sanitizer_print_stack_trace(); @@ -2336,10 +2347,12 @@ void Rx_igraph_error_handler(const char *reason, const char *file, * IGRAPH_FINALLY_FREE() can then clean it up. */ if (Rx_igraph_errors_count == 0 || !Rx_igraph_in_r_check) { + const char* simplified_path = simplify_file_path(file); snprintf(Rx_igraph_error_reason, sizeof(Rx_igraph_error_reason), - "At %s:%i : %s%s %s", file, line, reason, - maybe_add_punctuation(reason, ","), - igraph_strerror(igraph_errno)); + "%s%s %s\nSource: %s:%i", reason, + maybe_add_punctuation(reason, "."), + igraph_strerror(igraph_errno), + simplified_path, line); Rx_igraph_error_reason[sizeof(Rx_igraph_error_reason) - 1] = 0; // FIXME: This is a hack, we should replace all memory allocations in the @@ -2356,8 +2369,10 @@ void Rx_igraph_error_handler(const char *reason, const char *file, void Rx_igraph_warning_handler(const char *reason, const char *file, int line) { if (Rx_igraph_warnings_count == 0) { + const char* simplified_path = simplify_file_path(file); snprintf(Rx_igraph_warning_reason, sizeof(Rx_igraph_warning_reason), - "At %s:%i : %s%s", file, line, reason, maybe_add_punctuation(reason, ".")); + "%s%s\nSource: %s:%i", reason, maybe_add_punctuation(reason, "."), + simplified_path, line); Rx_igraph_warning_reason[sizeof(Rx_igraph_warning_reason) - 1] = 0; } Rx_igraph_warnings_count++; diff --git a/tests/testthat/_snaps/aaa-auto.md b/tests/testthat/_snaps/aaa-auto.md index 26e86730a08..7cf09c9412d 100644 --- a/tests/testthat/_snaps/aaa-auto.md +++ b/tests/testthat/_snaps/aaa-auto.md @@ -20,7 +20,8 @@ empty_impl(n = -1) Condition Error in `empty_impl()`: - ! At vendor/cigraph/src/graph/type_indexededgelist.c:xx : Number of vertices must not be negative. Invalid value + ! Number of vertices must not be negative. Invalid value + Source: graph/type_indexededgelist.c:xx # add_edges_impl basic @@ -155,7 +156,8 @@ wheel_impl(n = -1) Condition Error in `wheel_impl()`: - ! At vendor/cigraph/src/constructors/regular.c:xx : Invalid number of vertices. Invalid vertex ID + ! Invalid number of vertices. Invalid vertex ID + Source: constructors/regular.c:xx # hypercube_impl basic @@ -181,7 +183,8 @@ hypercube_impl(n = 10000) Condition Error in `hypercube_impl()`: - ! At vendor/cigraph/src/constructors/regular.c:xx : The requested hypercube graph dimension (10000) is too high. It must be no greater than 57. Invalid value + ! The requested hypercube graph dimension (10000) is too high. It must be no greater than 57. Invalid value + Source: constructors/regular.c:xx # square_lattice_impl basic @@ -208,7 +211,8 @@ square_lattice_impl(dimvector = -1) Condition Error in `square_lattice_impl()`: - ! At vendor/cigraph/src/constructors/regular.c:xx : Invalid dimension vector. Invalid value + ! Invalid dimension vector. Invalid value + Source: constructors/regular.c:xx # triangular_lattice_impl basic @@ -234,7 +238,8 @@ triangular_lattice_impl(dimvector = -1) Condition Error in `triangular_lattice_impl()`: - ! At vendor/cigraph/src/constructors/lattices.c:xx : Invalid dimension vector. Invalid value + ! Invalid dimension vector. Invalid value + Source: constructors/lattices.c:xx # path_graph_impl basic @@ -260,7 +265,8 @@ path_graph_impl(n = -1) Condition Error in `path_graph_impl()`: - ! At vendor/cigraph/src/constructors/regular.c:xx : The number of vertices must be non-negative, got -1. Invalid value + ! The number of vertices must be non-negative, got -1. Invalid value + Source: constructors/regular.c:xx # cycle_graph_impl basic @@ -286,7 +292,8 @@ cycle_graph_impl(n = -1) Condition Error in `cycle_graph_impl()`: - ! At vendor/cigraph/src/constructors/regular.c:xx : The number of vertices must be non-negative, got -1. Invalid value + ! The number of vertices must be non-negative, got -1. Invalid value + Source: constructors/regular.c:xx # symmetric_tree_impl basic @@ -312,7 +319,8 @@ symmetric_tree_impl(branches = -1) Condition Error in `symmetric_tree_impl()`: - ! At vendor/cigraph/src/constructors/regular.c:xx : The number of branches must be positive at each level. Invalid value + ! The number of branches must be positive at each level. Invalid value + Source: constructors/regular.c:xx # regular_tree_impl basic @@ -339,7 +347,8 @@ regular_tree_impl(h = -1) Condition Error in `regular_tree_impl()`: - ! At vendor/cigraph/src/constructors/regular.c:xx : Height of regular tree must be positive, got -1. Invalid value + ! Height of regular tree must be positive, got -1. Invalid value + Source: constructors/regular.c:xx # full_citation_impl basic @@ -365,7 +374,8 @@ full_citation_impl(n = -1) Condition Error in `full_citation_impl()`: - ! At vendor/cigraph/src/constructors/full.c:xx : Invalid number of vertices. Invalid value + ! Invalid number of vertices. Invalid value + Source: constructors/full.c:xx # atlas_impl basic @@ -390,7 +400,8 @@ atlas_impl(number = -1) Condition Error in `atlas_impl()`: - ! At vendor/cigraph/src/constructors/atlas.c:xx : No such graph in atlas. The graph index must be less than 1253. Invalid value + ! No such graph in atlas. The graph index must be less than 1253. Invalid value + Source: constructors/atlas.c:xx # extended_chordal_ring_impl basic @@ -416,7 +427,8 @@ extended_chordal_ring_impl(nodes = -1, W = matrix(c(1, 2))) Condition Error in `extended_chordal_ring_impl()`: - ! At vendor/cigraph/src/constructors/regular.c:xx : An extended chordal ring has at least 3 nodes. Invalid value + ! An extended chordal ring has at least 3 nodes. Invalid value + Source: constructors/regular.c:xx # graph_power_impl basic @@ -477,7 +489,8 @@ de_bruijn_impl(m = -1, n = 3) Condition Error in `de_bruijn_impl()`: - ! At vendor/cigraph/src/constructors/de_bruijn.c:xx : `m' and `n' should be non-negative in a de Bruijn graph, Invalid value + ! `m' and `n' should be non-negative in a de Bruijn graph. Invalid value + Source: constructors/de_bruijn.c:xx # kautz_impl basic @@ -498,7 +511,8 @@ kautz_impl(m = -1, n = 3) Condition Error in `kautz_impl()`: - ! At vendor/cigraph/src/constructors/kautz.c:xx : `m' and `n' should be non-negative in a Kautz graph, Invalid value + ! `m' and `n' should be non-negative in a Kautz graph. Invalid value + Source: constructors/kautz.c:xx # lcf_vector_impl basic @@ -517,7 +531,8 @@ lcf_vector_impl(n = -1, shifts = c(3, -3, 4), repeats = 2) Condition Error in `lcf_vector_impl()`: - ! At vendor/cigraph/src/graph/type_indexededgelist.c:xx : Number of vertices must not be negative. Invalid value + ! Number of vertices must not be negative. Invalid value + Source: graph/type_indexededgelist.c:xx # mycielski_graph_impl basic @@ -534,7 +549,8 @@ mycielski_graph_impl(k = -1) Condition Error in `mycielski_graph_impl()`: - ! At vendor/cigraph/src/constructors/mycielskian.c:xx : The Mycielski graph order must not be negative. Invalid value + ! The Mycielski graph order must not be negative. Invalid value + Source: constructors/mycielskian.c:xx # adjlist_impl basic @@ -551,7 +567,8 @@ adjlist_impl(adjlist = -1, mode = "out") Condition Error in `adjlist_impl()`: - ! At vendor/cigraph/src/constructors/basic_constructors.c:xx : Invalid (negative or too large) vertex ID. Invalid vertex ID + ! Invalid (negative or too large) vertex ID. Invalid vertex ID + Source: constructors/basic_constructors.c:xx # full_bipartite_impl basic @@ -587,7 +604,8 @@ full_bipartite_impl(n1 = -1, n2 = 3) Condition Error in `full_bipartite_impl()`: - ! At vendor/cigraph/src/misc/bipartite.c:xx : Invalid number of vertices for bipartite graph. Invalid value + ! Invalid number of vertices for bipartite graph. Invalid value + Source: misc/bipartite.c:xx # full_multipartite_impl basic @@ -643,7 +661,8 @@ full_multipartite_impl(n = -1) Condition Error in `full_multipartite_impl()`: - ! At vendor/cigraph/src/constructors/full.c:xx : Number of vertices must not be negative in any partition. Invalid value + ! Number of vertices must not be negative in any partition. Invalid value + Source: constructors/full.c:xx # realize_degree_sequence_impl basic @@ -674,7 +693,8 @@ realize_degree_sequence_impl(out_deg = -1) Condition Error in `realize_degree_sequence_impl()`: - ! At vendor/cigraph/src/misc/degree_sequence.cpp:xx : The sum of degrees must be even for an undirected graph. Invalid value + ! The sum of degrees must be even for an undirected graph. Invalid value + Source: misc/degree_sequence.cpp:xx # realize_bipartite_degree_sequence_impl basic @@ -705,7 +725,8 @@ realize_bipartite_degree_sequence_impl(degrees1 = -1, degrees2 = c(2, 2)) Condition Error in `realize_bipartite_degree_sequence_impl()`: - ! At vendor/cigraph/src/misc/degree_sequence.cpp:xx : The given bidegree sequence cannot be realized as a bipartite simple graph. Invalid value + ! The given bidegree sequence cannot be realized as a bipartite simple graph. Invalid value + Source: misc/degree_sequence.cpp:xx # circulant_impl basic @@ -733,7 +754,8 @@ circulant_impl(n = -1, shifts = c(1, 2)) Condition Error in `circulant_impl()`: - ! At vendor/cigraph/src/constructors/circulant.c:xx : Number of nodes = -1 must be non-negative. Invalid value + ! Number of nodes = -1 must be non-negative. Invalid value + Source: constructors/circulant.c:xx # generalized_petersen_impl basic @@ -751,7 +773,8 @@ generalized_petersen_impl(n = -1, k = 2) Condition Error in `generalized_petersen_impl()`: - ! At vendor/cigraph/src/constructors/generalized_petersen.c:xx : n = -1 must be at least 3. Invalid value + ! n = -1 must be at least 3. Invalid value + Source: constructors/generalized_petersen.c:xx # turan_impl basic @@ -782,7 +805,8 @@ turan_impl(n = -1, r = 2) Condition Error in `turan_impl()`: - ! At vendor/cigraph/src/constructors/full.c:xx : Number of vertices must not be negative, got -1. Invalid value + ! Number of vertices must not be negative, got -1. Invalid value + Source: constructors/full.c:xx # erdos_renyi_game_gnp_impl basic @@ -808,7 +832,8 @@ erdos_renyi_game_gnp_impl(n = -1, p = 0.5) Condition Error in `erdos_renyi_game_gnp_impl()`: - ! At vendor/cigraph/src/games/erdos_renyi.c:xx : Invalid number of vertices. Invalid value + ! Invalid number of vertices. Invalid value + Source: games/erdos_renyi.c:xx # erdos_renyi_game_gnm_impl basic @@ -834,7 +859,8 @@ erdos_renyi_game_gnm_impl(n = -1, m = 3) Condition Error in `erdos_renyi_game_gnm_impl()`: - ! At vendor/cigraph/src/games/erdos_renyi.c:xx : Invalid number of vertices. Invalid value + ! Invalid number of vertices. Invalid value + Source: games/erdos_renyi.c:xx # growing_random_game_impl basic @@ -862,7 +888,8 @@ growing_random_game_impl(n = -1, m = 2) Condition Error in `growing_random_game_impl()`: - ! At vendor/cigraph/src/games/growing_random.c:xx : Invalid number of vertices. Invalid value + ! Invalid number of vertices. Invalid value + Source: games/growing_random.c:xx # preference_game_impl basic @@ -886,7 +913,8 @@ fixed_sizes = FALSE, pref_matrix = matrix(c(0.5, 0.5, 0.5, 0.5), 2, 2)) Condition Error in `preference_game_impl()`: - ! At vendor/cigraph/src/games/preference.c:xx : The number of vertices must be non-negative. Invalid value + ! The number of vertices must be non-negative. Invalid value + Source: games/preference.c:xx # asymmetric_preference_game_impl basic @@ -915,7 +943,8 @@ c(0.5, 0.5, 0.5, 0.5), 2, 2)) Condition Error in `asymmetric_preference_game_impl()`: - ! At vendor/cigraph/src/games/preference.c:xx : The number of vertices must not be negative. Invalid value + ! The number of vertices must not be negative. Invalid value + Source: games/preference.c:xx # rewire_edges_impl basic @@ -978,7 +1007,8 @@ forest_fire_game_impl(nodes = -1, fw_prob = 0.5) Condition Error in `forest_fire_game_impl()`: - ! At vendor/cigraph/src/games/forestfire.c:xx : Insufficient memory for forest fire model. Out of memory + ! Insufficient memory for forest fire model. Out of memory + Source: games/forestfire.c:xx # simple_interconnected_islands_game_impl basic @@ -999,7 +1029,8 @@ islands_pin = 0.5, n_inter = 1) Condition Error in `simple_interconnected_islands_game_impl()`: - ! At vendor/cigraph/src/games/islands.c:xx : Number of islands cannot be negative, got -1. Invalid value + ! Number of islands cannot be negative, got -1. Invalid value + Source: games/islands.c:xx # chung_lu_game_impl basic @@ -1028,7 +1059,8 @@ chung_lu_game_impl(out_weights = -1) Condition Error in `chung_lu_game_impl()`: - ! At vendor/cigraph/src/games/chung_lu.c:xx : Vertex weights must not be negative in Chung-Lu model, got -1. Invalid value + ! Vertex weights must not be negative in Chung-Lu model, got -1. Invalid value + Source: games/chung_lu.c:xx # static_fitness_game_impl basic @@ -1057,7 +1089,8 @@ static_fitness_game_impl(no_of_edges = -1, fitness_out = c(1, 2, 3)) Condition Error in `static_fitness_game_impl()`: - ! At vendor/cigraph/src/games/static_fitness.c:xx : Number of edges cannot be negative, got -1. Invalid value + ! Number of edges cannot be negative, got -1. Invalid value + Source: games/static_fitness.c:xx # static_power_law_game_impl basic @@ -1088,7 +1121,8 @@ static_power_law_game_impl(no_of_nodes = -1, no_of_edges = 4, exponent_out = 2.5) Condition Error in `static_power_law_game_impl()`: - ! At vendor/cigraph/src/games/static_fitness.c:xx : Number of nodes cannot be negative, got -1. Invalid value + ! Number of nodes cannot be negative, got -1. Invalid value + Source: games/static_fitness.c:xx # k_regular_game_impl basic @@ -1116,7 +1150,8 @@ k_regular_game_impl(no_of_nodes = -1, k = 2) Condition Error in `k_regular_game_impl()`: - ! At vendor/cigraph/src/games/k_regular.c:xx : Number of nodes must be non-negative. Invalid value + ! Number of nodes must be non-negative. Invalid value + Source: games/k_regular.c:xx # sbm_game_impl basic @@ -1145,7 +1180,8 @@ sbm_game_impl(n = -1, pref_matrix = matrix(0.5, 2, 2), block_sizes = c(2, 3)) Condition Error in `sbm_game_impl()`: - ! At vendor/cigraph/src/games/sbm.c:xx : Sum of the block sizes (5) must equal the number of vertices (-1). Invalid value + ! Sum of the block sizes (5) must equal the number of vertices (-1). Invalid value + Source: games/sbm.c:xx # hsbm_game_impl basic @@ -1163,7 +1199,8 @@ hsbm_game_impl(n = -1, m = 2, rho = 0.5, C = matrix(1, 2, 2), p = 0.5) Condition Error in `hsbm_game_impl()`: - ! At vendor/cigraph/src/games/sbm.c:xx : `n' must be positive for HSBM, Invalid value + ! `n' must be positive for HSBM. Invalid value + Source: games/sbm.c:xx # hsbm_list_game_impl basic @@ -1191,7 +1228,8 @@ matrix(1, 2, 2), matrix(1, 2, 2)), p = 0.5) Condition Error in `hsbm_list_game_impl()`: - ! At vendor/cigraph/src/games/sbm.c:xx : `n' must be positive for HSBM. Invalid value + ! `n' must be positive for HSBM. Invalid value + Source: games/sbm.c:xx # correlated_game_impl basic @@ -1249,7 +1287,8 @@ correlated_pair_game_impl(n = -1, corr = 0.5, p = 0.5) Condition Error in `correlated_pair_game_impl()`: - ! At vendor/cigraph/src/games/erdos_renyi.c:xx : Invalid number of vertices. Invalid value + ! Invalid number of vertices. Invalid value + Source: games/erdos_renyi.c:xx # dot_product_game_impl basic @@ -1257,7 +1296,8 @@ dot_product_game_impl(vecs = matrix(0.5, 5, 2)) Condition Warning in `dot_product_game_impl()`: - At vendor/cigraph/src/games/dotproduct.c:90 : Greater than 1 connection probability in dot-product graph. + Greater than 1 connection probability in dot-product graph. + Source: games/dotproduct.c:90 Output IGRAPH U--- 2 1 -- + edge: @@ -1269,7 +1309,8 @@ dot_product_game_impl(vecs = matrix(0.5, 5, 2), directed = TRUE) Condition Warning in `dot_product_game_impl()`: - At vendor/cigraph/src/games/dotproduct.c:90 : Greater than 1 connection probability in dot-product graph. + Greater than 1 connection probability in dot-product graph. + Source: games/dotproduct.c:90 Output IGRAPH D--- 2 2 -- + edges: @@ -1309,7 +1350,8 @@ sample_sphere_surface_impl(dim = -1, n = 5) Condition Error in `sample_sphere_surface_impl()`: - ! At vendor/cigraph/src/games/dotproduct.c:xx : Sphere must be at least two dimensional to sample from surface. Invalid value + ! Sphere must be at least two dimensional to sample from surface. Invalid value + Source: games/dotproduct.c:xx # sample_sphere_volume_impl basic @@ -1337,7 +1379,8 @@ sample_sphere_volume_impl(dim = -1, n = 5) Condition Error in `sample_sphere_volume_impl()`: - ! At vendor/cigraph/src/games/dotproduct.c:xx : Sphere must be at least two dimensional to sample from surface. Invalid value + ! Sphere must be at least two dimensional to sample from surface. Invalid value + Source: games/dotproduct.c:xx # sample_dirichlet_impl basic @@ -1355,7 +1398,8 @@ sample_dirichlet_impl(n = -1, alpha = c(1, 1, 1)) Condition Error in `sample_dirichlet_impl()`: - ! At vendor/cigraph/src/games/dotproduct.c:xx : Number of samples should be non-negative, got -1. Invalid value + ! Number of samples should be non-negative, got -1. Invalid value + Source: games/dotproduct.c:xx # are_adjacent_impl basic @@ -2174,7 +2218,8 @@ transitivity_barrat_impl(graph = g) Condition Warning in `transitivity_barrat_impl()`: - At vendor/cigraph/src/properties/triangles.c:913 : No weights given for Barrat's transitivity, unweighted version is used. + No weights given for Barrat's transitivity, unweighted version is used. + Source: properties/triangles.c:913 Output [1] NaN 0 NaN @@ -2184,7 +2229,8 @@ transitivity_barrat_impl(graph = g, mode = "zero") Condition Warning in `transitivity_barrat_impl()`: - At vendor/cigraph/src/properties/triangles.c:913 : No weights given for Barrat's transitivity, unweighted version is used. + No weights given for Barrat's transitivity, unweighted version is used. + Source: properties/triangles.c:913 Output [1] 0 0 0 @@ -3092,7 +3138,8 @@ centralization_degree_tmax_impl(nodes = -1, loops = TRUE) Condition Error in `centralization_degree_tmax_impl()`: - ! At vendor/cigraph/src/centrality/centralization.c:xx : Number of vertices must not be negative. Invalid value + ! Number of vertices must not be negative. Invalid value + Source: centrality/centralization.c:xx # centralization_betweenness_impl basic @@ -3152,7 +3199,8 @@ centralization_betweenness_tmax_impl(nodes = -1, directed = TRUE) Condition Error in `centralization_betweenness_tmax_impl()`: - ! At vendor/cigraph/src/centrality/centralization.c:xx : Number of vertices must not be negative. Invalid value + ! Number of vertices must not be negative. Invalid value + Source: centrality/centralization.c:xx # centralization_closeness_impl basic @@ -3212,7 +3260,8 @@ centralization_closeness_tmax_impl(nodes = -1) Condition Error in `centralization_closeness_tmax_impl()`: - ! At vendor/cigraph/src/centrality/centralization.c:xx : Number of vertices must not be negative. Invalid value + ! Number of vertices must not be negative. Invalid value + Source: centrality/centralization.c:xx # centralization_eigenvector_centrality_impl basic @@ -3403,7 +3452,8 @@ centralization_eigenvector_centrality_tmax_impl(nodes = -1) Condition Error in `centralization_eigenvector_centrality_tmax_impl()`: - ! At vendor/cigraph/src/centrality/centralization.c:xx : Number of vertices must not be negative. Invalid value + ! Number of vertices must not be negative. Invalid value + Source: centrality/centralization.c:xx # assortativity_nominal_impl basic @@ -3907,7 +3957,8 @@ Warning in `is_graphical_impl()`: NAs introduced by coercion Error in `is_graphical_impl()`: - ! At rinterface_extra.c:xx : The value nan is not representable as an integer. Invalid value + ! The value nan is not representable as an integer. Invalid value + Source: rinterface_extra.c:xx # bfs_simple_impl basic @@ -4091,7 +4142,8 @@ bipartite_game_gnp_impl(n1 = -1, n2 = 2, p = 0.5) Condition Error in `bipartite_game_gnp_impl()`: - ! At vendor/cigraph/src/misc/bipartite.c:xx : Invalid number of vertices for bipartite graph. Invalid value + ! Invalid number of vertices for bipartite graph. Invalid value + Source: misc/bipartite.c:xx # bipartite_game_gnm_impl basic @@ -4127,7 +4179,8 @@ bipartite_game_gnm_impl(n1 = -1, n2 = 2, m = 1) Condition Error in `bipartite_game_gnm_impl()`: - ! At vendor/cigraph/src/misc/bipartite.c:xx : Invalid number of vertices for bipartite graph. Invalid value + ! Invalid number of vertices for bipartite graph. Invalid value + Source: misc/bipartite.c:xx # get_laplacian_impl basic @@ -5342,7 +5395,8 @@ Warning in `compare_communities_impl()`: NAs introduced by coercion Error in `compare_communities_impl()`: - ! At rinterface_extra.c:xx : The value nan is not representable as an integer. Invalid value + ! The value nan is not representable as an integer. Invalid value + Source: rinterface_extra.c:xx # modularity_impl basic @@ -5550,7 +5604,8 @@ Warning in `split_join_distance_impl()`: NAs introduced by coercion Error in `split_join_distance_impl()`: - ! At rinterface_extra.c:xx : The value nan is not representable as an integer. Invalid value + ! The value nan is not representable as an integer. Invalid value + Source: rinterface_extra.c:xx # community_infomap_impl basic @@ -5765,7 +5820,8 @@ hrg_create_impl(graph = g, prob = 0.5) Condition Error in `hrg_create_impl()`: - ! At vendor/cigraph/src/hrg/hrg.cc:xx : HRG probability vector size (1) should be equal to the number of internal nodes (2). Invalid value + ! HRG probability vector size (1) should be equal to the number of internal nodes (2). Invalid value + Source: hrg/hrg.cc:xx # hrg_resize_impl basic @@ -5794,7 +5850,8 @@ hrg_resize_impl(hrg = -1, newsize = 2) Condition Error in `hrg_resize_impl()`: - ! At rinterface_extra.c:xx : The value nan is not representable as an integer. Invalid value + ! The value nan is not representable as an integer. Invalid value + Source: rinterface_extra.c:xx # hrg_size_impl basic @@ -5809,7 +5866,8 @@ hrg_size_impl(hrg = -1) Condition Error in `hrg_size_impl()`: - ! At rinterface_extra.c:xx : The value nan is not representable as an integer. Invalid value + ! The value nan is not representable as an integer. Invalid value + Source: rinterface_extra.c:xx # from_hrg_dendrogram_impl basic @@ -5832,7 +5890,8 @@ from_hrg_dendrogram_impl(hrg = -1) Condition Error in `from_hrg_dendrogram_impl()`: - ! At rinterface_extra.c:xx : The value nan is not representable as an integer. Invalid value + ! The value nan is not representable as an integer. Invalid value + Source: rinterface_extra.c:xx # get_adjacency_sparse_impl basic @@ -6087,7 +6146,8 @@ motifs_randesu_no_impl(graph = g, size = 3, cut_prob = c(0.1)) Condition Error in `motifs_randesu_no_impl()`: - ! At vendor/cigraph/src/misc/motifs.c:xx : Cut probability vector size (1) must agree with motif size (3). Invalid value + ! Cut probability vector size (1) must agree with motif size (3). Invalid value + Source: misc/motifs.c:xx # dyad_census_impl basic @@ -6118,7 +6178,8 @@ triad_census_impl(graph = g) Condition Warning in `triad_census_impl()`: - At vendor/cigraph/src/misc/motifs.c:1157 : Triad census called on an undirected graph. All connections will be treated as mutual. + Triad census called on an undirected graph. All connections will be treated as mutual. + Source: misc/motifs.c:1157 Output [1] 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 @@ -7000,7 +7061,8 @@ Warning in `isoclass_create_impl()`: NAs introduced by coercion Error in `isoclass_create_impl()`: - ! At rinterface_extra.c:xx : The value nan is not representable as an integer. Invalid value + ! The value nan is not representable as an integer. Invalid value + Source: rinterface_extra.c:xx # isomorphic_vf2_impl basic @@ -7553,7 +7615,8 @@ Warning in `graph_count_impl()`: NAs introduced by coercion Error in `graph_count_impl()`: - ! At rinterface_extra.c:xx : The value nan is not representable as an integer. Invalid value + ! The value nan is not representable as an integer. Invalid value + Source: rinterface_extra.c:xx # is_matching_impl basic @@ -7986,7 +8049,8 @@ options = list(maxiter = 10)) Condition Error in `eigen_adjacency_impl()`: - ! At vendor/cigraph/src/linalg/eigen.c:xx : 'LAPACK' algorithm not implemented yet, Unimplemented function call + ! 'LAPACK' algorithm not implemented yet. Unimplemented function call + Source: linalg/eigen.c:xx # eigen_adjacency_impl errors @@ -8046,7 +8110,8 @@ Warning in `power_law_fit_impl()`: NAs introduced by coercion Error in `power_law_fit_impl()`: - ! At vendor/cigraph/src/misc/power_law_fit.c:xx : xmin must be greater than zero, Invalid value + ! xmin must be greater than zero. Invalid value + Source: misc/power_law_fit.c:xx # sir_impl basic @@ -9537,7 +9602,8 @@ dim_select_impl(sv = NULL) Condition Error in `dim_select_impl()`: - ! At vendor/cigraph/src/misc/embedding.c:xx : Need at least one singular value for dimensionality selection, Invalid value + ! Need at least one singular value for dimensionality selection. Invalid value + Source: misc/embedding.c:xx # solve_lsap_impl basic @@ -9669,7 +9735,8 @@ eulerian_cycle_impl(graph = g1) Condition Error in `eulerian_cycle_impl()`: - ! At vendor/cigraph/src/paths/eulerian.c:xx : The graph does not have an Eulerian cycle. Input problem has no solution + ! The graph does not have an Eulerian cycle. Input problem has no solution + Source: paths/eulerian.c:xx --- @@ -9812,7 +9879,8 @@ Warning in `from_prufer_impl()`: NAs introduced by coercion Error in `from_prufer_impl()`: - ! At rinterface_extra.c:xx : The value nan is not representable as an integer. Invalid value + ! The value nan is not representable as an integer. Invalid value + Source: rinterface_extra.c:xx # to_prufer_impl basic @@ -9855,7 +9923,8 @@ Warning in `tree_from_parent_vector_impl()`: NAs introduced by coercion Error in `tree_from_parent_vector_impl()`: - ! At rinterface_extra.c:xx : The value nan is not representable as an integer. Invalid value + ! The value nan is not representable as an integer. Invalid value + Source: rinterface_extra.c:xx # is_complete_impl basic @@ -9914,7 +9983,8 @@ Warning in `tree_game_impl()`: NAs introduced by coercion Error in `tree_game_impl()`: - ! At rinterface_extra.c:xx : The value nan is not representable as an integer. Invalid value + ! The value nan is not representable as an integer. Invalid value + Source: rinterface_extra.c:xx # vertex_coloring_greedy_impl basic @@ -10310,7 +10380,8 @@ famous_impl(name = "NonexistentGraph") Condition Error in `famous_impl()`: - ! At vendor/cigraph/src/constructors/famous.c:xx : NonexistentGraph is not a known graph. See the documentation for valid graph names. Invalid value + ! NonexistentGraph is not a known graph. See the documentation for valid graph names. Invalid value + Source: constructors/famous.c:xx # constraint_impl errors diff --git a/tests/testthat/_snaps/centrality.md b/tests/testthat/_snaps/centrality.md index 62a6c46264f..a676e0e14ef 100644 --- a/tests/testthat/_snaps/centrality.md +++ b/tests/testthat/_snaps/centrality.md @@ -48,7 +48,8 @@ arpack(f, options = list(nev = 2, ncv = 4), sym = TRUE) Condition Error in `arpack()`: - ! At vendor/cigraph/src/linalg/arpack.c:1102 : ARPACK error, N must be positive + ! ARPACK error. N must be positive + Source: linalg/arpack.c: --- diff --git a/tests/testthat/_snaps/games.md b/tests/testthat/_snaps/games.md index 922ef9a505f..15522aa0df9 100644 --- a/tests/testthat/_snaps/games.md +++ b/tests/testthat/_snaps/games.md @@ -4,7 +4,8 @@ sample_degseq(exponential_degrees, method = "vl") Condition Error in `sample_degseq()`: - ! At vendor/cigraph/src/games/degree_sequence_vl/gengraph_mr-connected.cpp: : Cannot make a connected graph from the given degree sequence. Invalid value + ! Cannot make a connected graph from the given degree sequence. Invalid value + Source: games/degree_sequence_vl/gengraph_mr-connected.cpp: # sample_degseq() works -- Power-law degree error @@ -12,5 +13,6 @@ sample_degseq(powerlaw_degrees, method = "vl") Condition Error in `sample_degseq()`: - ! At vendor/cigraph/src/games/degree_sequence_vl/gengraph_mr-connected.cpp: : Cannot realize the given degree sequence as an undirected, simple graph. Invalid value + ! Cannot realize the given degree sequence as an undirected, simple graph. Invalid value + Source: games/degree_sequence_vl/gengraph_mr-connected.cpp: diff --git a/tests/testthat/test-centrality.R b/tests/testthat/test-centrality.R index 41653455073..2f983e74f8c 100644 --- a/tests/testthat/test-centrality.R +++ b/tests/testthat/test-centrality.R @@ -845,9 +845,13 @@ test_that("eigen_centrality() deprecated scale argument", { test_that("arpack() errors well", { f <- function(x, extra = NULL) x - expect_snapshot(error = TRUE, { - arpack(f, options = list(nev = 2, ncv = 4), sym = TRUE) - }) + expect_snapshot( + error = TRUE, + { + arpack(f, options = list(nev = 2, ncv = 4), sym = TRUE) + }, + transform = function(x) sub("\\:[0-9]+", ":", x) + ) expect_snapshot(error = TRUE, { arpack( f,