Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nfrerebeau committed Nov 27, 2023
1 parent f223d4a commit 83c6a0b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
Binary file added inst/tinytest/_snaps/aggregate_group.rds
Binary file not shown.
Binary file added inst/tinytest/_snaps/aggregate_sample.rds
Binary file not shown.
Binary file added inst/tinytest/_snaps/dist_mahalanobis.rds
Binary file not shown.
14 changes: 14 additions & 0 deletions inst/tinytest/test_dist.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
data("hongite")
coda <- as_composition(hongite)

# Aitchison distance ===========================================================
expect_equal_to_reference(
dist(coda, method = "euclidean", diag = TRUE, upper = TRUE),
file = "_snaps/dist_euclidean.rds"
)

# Mahalanobis distance =========================================================
expect_equal_to_reference(
mahalanobis(coda, robust = FALSE),
file = "_snaps/dist_mahalanobis.rds"
)
17 changes: 10 additions & 7 deletions inst/tinytest/test_statistics.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
# Aggregate ====================================================================
data("slides")
petro <- as_composition(slides, group = 1, sample = 2)

expect_equal_to_reference(aggregate(petro, by = "sample", FUN = mean),
file = "_snaps/aggregate_sample.rds")
expect_equal_to_reference(aggregate(petro, by = "group", FUN = mean),
file = "_snaps/aggregate_group.rds")

# Mean =========================================================================
data("hongite")
coda <- as_composition(hongite)

# Mean =========================================================================
expect_equal_to_reference(mean(coda), file = "_snaps/mean.rds")

# Scale ========================================================================
Expand All @@ -27,9 +36,3 @@ expect_equal_to_reference(covariance(coda, center = TRUE), file = "_snaps/covari

# Variation array ==============================================================
# expect_equal_to_reference(variation_array(coda), file = "_snaps/variation_array.rds")

# Aitchison distance ===========================================================
expect_equal_to_reference(
dist(coda, method = "euclidean", diag = TRUE, upper = TRUE),
file = "_snaps/dist_euclidean.rds"
)

0 comments on commit 83c6a0b

Please sign in to comment.