Skip to content

Commit

Permalink
Remove usage of |>
Browse files Browse the repository at this point in the history
Resolves #128
  • Loading branch information
mitchelloharawild committed Oct 15, 2024
1 parent f205f8a commit 2a2db76
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
6 changes: 2 additions & 4 deletions R/mixture.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ dist_mixture <- function(..., weights = numeric()){

#' @export
format.dist_mixture <- function(x, width = getOption("width"), ...){
dists <- lapply(x[["dist"]], format) |>
unlist()
dists <- unlist(lapply(x[["dist"]], format))

dist_info <- paste0(x[["w"]], "*", dists) |>
paste0(collapse = ", ")
dist_info <- paste0(x[["w"]], "*", dists, collapse = ", ")

long_dist <- paste0("mixture(", dist_info, ")")
short_dist <- paste0("mixture(n=", length(dists), ")")
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test_gev.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ test_that("GEV", {
# Generate
set.seed(123)
rand_dist <- distributional::generate(dist, times = 1e6)
expect_equal(lapply(rand_dist[1:2], mean) |> unlist(),
expect_equal(unlist(lapply(rand_dist[1:2], mean)),
mean(dist)[1:2],
tolerance = 0.01
)
expect_equal(lapply(rand_dist[1:2], var) |> unlist(),
expect_equal(unlist(lapply(rand_dist[1:2], var)),
distributional::variance(dist)[1:2],
tolerance = 0.01
)
expect_equal(lapply(rand_dist, median) |> unlist(),
expect_equal(unlist(lapply(rand_dist, median)),
median(dist),
tolerance = 0.01
)
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test_gpd.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ test_that("GPD", {
# Generate
set.seed(123)
rand_dist <- distributional::generate(dist, times = 1e6)
expect_equal(lapply(rand_dist[1:2], mean) |> unlist(),
expect_equal(unlist(lapply(rand_dist[1:2], mean)),
mean(dist)[1:2],
tolerance = 0.01
)
expect_equal(lapply(rand_dist[1:2], var) |> unlist(),
expect_equal(unlist(lapply(rand_dist[1:2], var)),
distributional::variance(dist)[1:2],
tolerance = 0.01
)
expect_equal(lapply(rand_dist, median) |> unlist(),
expect_equal(unlist(lapply(rand_dist, median)),
median(dist),
tolerance = 0.01
)
Expand Down

0 comments on commit 2a2db76

Please sign in to comment.