@@ -42,18 +42,27 @@ jsd <- function(x, weighted = TRUE, threads = 1) {
4242
4343 # # Error handling
4444 # --------------------------------------------------------------------#
45+ if (is.vector(x ))
46+ cli :: cli_abort(" {.val x} must be a {.cls matrix}, {.cls denseMatrix} or {.cls sparseMatrix}, not a {.cls vector}." )
47+
4548 if (inherits(x , " denseMatrix" ) || inherits(x , " matrix" ) || inherits(x , " sparseMatrix" )) {
4649 x <- methods :: as(x , " CsparseMatrix" )
47- } else cli :: cli_abort(" Input isn't a {.cls matrix}, {.cls denseMatrix} or {.cls sparseMatrix}." )
50+ } else cli :: cli_abort(" {.val x} isn't a {.cls matrix}, {.cls denseMatrix} or {.cls sparseMatrix}." )
4851
4952 if (! is.numeric(x @ x ))
50- cli :: cli_abort(" Input data must be numeric." )
53+ cli :: cli_abort(" {.val x} must be numeric." )
5154
5255 if (any(x @ x < 0 , na.rm = TRUE ))
53- cli :: cli_abort(" Input data must be non-negative." )
56+ cli :: cli_abort(" {.val x} must be non-negative." )
57+
58+ if (! is.logical(weighted ))
59+ cli :: cli_abort(" {.val weighted} needs to be either `TRUE` or `FALSE`." )
5460
55- if (! is.wholenumber(threads ))
61+ if (length(threads ) != 1 ) {
62+ cli :: cli_abort(" {.val threads} must be a single whole number." )
63+ } else if (! is.wholenumber(threads )) {
5664 cli :: cli_abort(" {.val {threads}} must be a whole number." )
65+ }
5766
5867 # # MAIN
5968 # --------------------------------------------------------------------#
0 commit comments