File tree Expand file tree Collapse file tree 3 files changed +41
-1
lines changed Expand file tree Collapse file tree 3 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -287,6 +287,11 @@ hrg <- hrg_create_impl
287
287
# ' @export
288
288
# ' @cdocs igraph_from_hrg_dendrogram
289
289
hrg_tree <- function (hrg ) {
290
+
291
+ if (! inherits(hrg , " igraphHRG" )) {
292
+ cli :: cli_abort(" {.arg hrg} must be an {.cls igraphHRG} object, not {.obj_type_friendly {hrg}}." )
293
+ }
294
+
290
295
out <- from_hrg_dendrogram_impl(hrg )
291
296
292
297
g <- out $ graph
@@ -305,8 +310,14 @@ hrg_tree <- function(hrg) {
305
310
# ' @family hierarchical random graph functions
306
311
# ' @export
307
312
# ' @cdocs igraph_hrg_game
308
- sample_hrg <- hrg_game_impl
313
+ sample_hrg <- function ( hrg ) {
309
314
315
+ if (! inherits(hrg , " igraphHRG" )) {
316
+ cli :: cli_abort(" {.arg hrg} must be an {.cls igraphHRG} object, not {.obj_type_friendly {hrg}}." )
317
+ }
318
+
319
+ hrg_game_impl(hrg )
320
+ }
310
321
# ' Predict edges based on a hierarchical random graph model
311
322
# '
312
323
# ' `predict_edges()` uses a hierarchical random graph model to predict
Original file line number Diff line number Diff line change 11
11
method 1 -none- character
12
12
dist.method 1 -none- character
13
13
14
+ # sample_hrg() checks its argument
15
+
16
+ Code
17
+ sample_hrg(make_ring(10))
18
+ Condition
19
+ Error in `sample_hrg()`:
20
+ ! `hrg` must be an <igraphHRG> object, not an <igraph> object.
21
+
22
+ # hrg_tree() checks its argument
23
+
24
+ Code
25
+ hrg_tree(make_ring(10))
26
+ Condition
27
+ Error in `hrg_tree()`:
28
+ ! `hrg` must be an <igraphHRG> object, not an <igraph> object.
29
+
Original file line number Diff line number Diff line change @@ -16,3 +16,16 @@ test_that("as.hclust.igraphHRG() works", {
16
16
summary(as.hclust(hrg ))
17
17
})
18
18
})
19
+
20
+ test_that(" sample_hrg() checks its argument" , {
21
+ expect_snapshot(error = TRUE , {
22
+ sample_hrg(make_ring(10 ))
23
+ })
24
+ })
25
+
26
+
27
+ test_that(" hrg_tree() checks its argument" , {
28
+ expect_snapshot(error = TRUE , {
29
+ hrg_tree(make_ring(10 ))
30
+ })
31
+ })
You can’t perform that action at this time.
0 commit comments