Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaitlyn Johnson committed Feb 3, 2025
1 parent da21cd1 commit 6723975
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/testthat/test-apply_delay.R
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,18 @@ test_that("calc_expectation function works correctly", {
# Test 2: Check if the function modifies the correct cells
original <- expectation
modified <- calc_expectation(3, expectation, n_dates, delay_pmf)
expect_equal(modified[1:8, ], original[1:8, ])
expect_equal(modified[1:8, ], original[1:8, ], tolerance = 1e-6)
expect_false(all(modified[9:10, 3] == original[9:10, 3]))

# Test 3: Check if the calculation is correct
block_bottom_left <- expectation[9:10, 1:2]
exp_total <- rowSums(block_bottom_left) / sum(delay_pmf[1:2])
expected_values <- exp_total * delay_pmf[3]
expect_equal(modified[9:10, 3], expected_values)
expect_identical(modified[9:10, 3], expected_values)

# Test 4: Edge case - when co is 2
result_edge <- calc_expectation(2, expectation, n_dates, delay_pmf)
expect_equal(dim(result_edge), c(n_dates, n_delays))
expect_identical(dim(result_edge), as.integer(c(n_dates, n_delays)))

# Test 5: Error handling - invalid co
expect_error(calc_expectation(1, expectation, n_dates, delay_pmf))
Expand Down

0 comments on commit 6723975

Please sign in to comment.