Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wincowgerDEV committed Dec 7, 2023
1 parent ac76b43 commit a9fea81
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion R/match_spec.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#' \code{max_cor_named()} formats the top correlation values from a correlation
#' matrix as a named vector.
#' \code{filter_spec()} filters an Open Specy object.
#'
#' \code{os_similarity()} EXPERIMENTAL, returns a single similarity metric between two OpenSpecy objects based on the method.
#' @param x an \code{OpenSpecy} object, typically with unknowns.
#' @param conform Whether to conform the spectra to the library wavenumbers or not.
#' @param type the type of conformation to make returned by \code{conform_spec()}
Expand All @@ -34,6 +34,7 @@
#' @param logic a logical or numeric vector describing which spectra to keep.
#' @param fill an \code{OpenSpecy} object with a single spectrum to be used to
#' fill missing values for alignment with the AI classification.
#' @param method the type of similarity metric to return.
#' @param \ldots additional arguments passed \code{\link[stats]{cor}()}.
#'
#' @return
Expand All @@ -54,6 +55,7 @@
#' \code{cor_spec()} returns a correlation matrix.
#' \code{get_metadata()} returns a \code{\link[data.table]{data.table-class}()}
#' with the metadata for columns which have information.
#' \code{os_similarity()} returns a single numeric value representing the type of similarity metric requested.
#'
#' @examples
#' data("test_lib")
Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test-match_spec.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ preproc <- conform_spec(unknown, range = test_lib$wavenumber,
res = spec_res(test_lib)) |>
process_spec(smooth_intens = T, make_rel = T)


test_that("os_similarity() handles input errors correctly", {
os_similarity()
})

test_that("ai_classify() handles input errors correctly", {
ai_classify(1:1000) |> expect_error()
})
Expand Down

0 comments on commit a9fea81

Please sign in to comment.