Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests #71

Merged
merged 29 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6f2f94c
Move tests to dedicated script
jamesmbaazam Sep 13, 2023
a463f19
Add test for checks
jamesmbaazam Sep 13, 2023
39ccbb2
Add test for simulation functions
jamesmbaazam Sep 13, 2023
267b995
Clean up the tests
jamesmbaazam Sep 13, 2023
042388c
Generate likelihood doc file
jamesmbaazam Sep 13, 2023
98dd76a
Use expect_identical instead of expect_equal
jamesmbaazam Sep 14, 2023
bbab69d
Use expect_null instead of expect_equal
jamesmbaazam Sep 14, 2023
fbc65ac
Fix expected data types
jamesmbaazam Sep 14, 2023
e40fd81
Add tests for utils.R
jamesmbaazam Sep 14, 2023
c9ed2ec
Add tests for epichains classes and methods
jamesmbaazam Sep 14, 2023
3584b3b
Add tests for the helper functions
jamesmbaazam Sep 14, 2023
c394326
Linting
jamesmbaazam Sep 14, 2023
29a7395
Add more tests for the simulation functions
jamesmbaazam Sep 14, 2023
d68b62a
Replace snapshot test of returned functions with a check for the requ…
jamesmbaazam Sep 15, 2023
020c7d4
Reinstate the snapshot tests of functions returning functions
jamesmbaazam Sep 15, 2023
67eb4d2
Move simulations within tests to top of script
jamesmbaazam Sep 15, 2023
0b42272
Add tests for simulated outcomes
jamesmbaazam Sep 15, 2023
aa4579d
Add fix=TRUE to fix the pattern to be matched
jamesmbaazam Sep 15, 2023
f9a32a0
Fix comment tags
jamesmbaazam Sep 15, 2023
5e60ed9
Lint
jamesmbaazam Sep 15, 2023
d6f4323
Remove snapshot tests
jamesmbaazam Sep 18, 2023
45b22e8
Remove tests for the get_offspring_func() helper
jamesmbaazam Sep 18, 2023
fdf45f8
Restructure tests-epichains by moving simulations into individual con…
jamesmbaazam Sep 19, 2023
395641d
Restructure test-simulate by moving simulations into individual contexts
jamesmbaazam Sep 19, 2023
e90b972
Rename file
jamesmbaazam Sep 19, 2023
d6aaa79
Linting
jamesmbaazam Sep 19, 2023
537ceab
Linting
jamesmbaazam Sep 19, 2023
01c5ef9
Add tests for the class of the head and tail methods
jamesmbaazam Sep 19, 2023
356a44c
Re-generate snaps
jamesmbaazam Sep 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions man/likelihood.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

218 changes: 218 additions & 0 deletions tests/testthat/_snaps/epichains.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
# print.epichains works for simulation functions

Code
susc_outbreak_raw
Output
`epichains` object

< tree head (from first known ancestor) >

[1] sim_id ancestor generation time
<0 rows> (or 0-length row.names)

< tree tail >

sim_id ancestor generation time
1 1 NA 1 0
Number of ancestors (known): 0
Number of generations: 1
Use `as.data.frame(<object_name>)` to view the full output in the console.

---

Code
susc_outbreak_raw2
Output
`epichains` object

< tree head (from first known ancestor) >

sim_id ancestor generation time
2 2 1 2 21.5834705
3 3 1 2 0.3939008
4 4 2 3 21.6595273

< tree tail >

sim_id ancestor generation time
1 1 NA 1 0.0000000
2 2 1 2 21.5834705
3 3 1 2 0.3939008
4 4 2 3 21.6595273
Number of ancestors (known): 2
Number of generations: 3
Use `as.data.frame(<object_name>)` to view the full output in the console.

---

Code
tree_sim_raw
Output
`epichains` object

< tree head (from first known ancestor) >

chain_id sim_id ancestor generation
3 1 2 1 2
4 1 3 1 2

< tree tail >

chain_id sim_id ancestor generation
1 1 1 NA 1
2 2 1 NA 1
3 1 2 1 2
4 1 3 1 2
Chains simulated: 2
Number of ancestors (known): 1
Number of generations: 2
Use `as.data.frame(<object_name>)` to view the full output in the console.

---

Code
tree_sim_raw2
Output
`epichains` object

< tree head (from first known ancestor) >

chain_id sim_id ancestor generation time
11 1 2 1 2 3
13 2 2 1 2 3
15 3 2 1 2 3
17 4 2 1 2 3
19 6 2 1 2 3
20 7 2 1 2 3

< tree tail >

chain_id sim_id ancestor generation time
92 9 19 8 4 9
109 6 19 8 5 12
93 9 20 9 4 9
110 6 20 9 5 12
94 9 21 9 4 9
111 6 21 9 5 12
Chains simulated: 10
Number of ancestors (known): 9
Number of generations: 5
Use `as.data.frame(<object_name>)` to view the full output in the console.

---

Code
chain_summary_raw
Output
`epichains` object

[1] 4 1

Simulated chain lengths:

Max: 4
Min: 1

# head and tail print output as expected

Code
head(susc_outbreak_raw)
Output
< tree head (from first known ancestor) >

[1] sim_id ancestor generation time
<0 rows> (or 0-length row.names)

---

Code
head(susc_outbreak_raw2)
Output
< tree head (from first known ancestor) >

sim_id ancestor generation time
2 2 1 2 21.5834705
3 3 1 2 0.3939008
4 4 2 3 21.6595273

---

Code
head(tree_sim_raw)
Output
< tree head (from first known ancestor) >

chain_id sim_id ancestor generation
3 1 2 1 2
4 1 3 1 2

---

Code
head(tree_sim_raw2)
Output
< tree head (from first known ancestor) >

chain_id sim_id ancestor generation time
11 1 2 1 2 3
13 2 2 1 2 3
15 3 2 1 2 3
17 4 2 1 2 3
19 6 2 1 2 3
20 7 2 1 2 3

---

Code
tail(susc_outbreak_raw)
Output

< tree tail >

sim_id ancestor generation time
1 1 NA 1 0

---

Code
tail(susc_outbreak_raw2)
Output

< tree tail >

sim_id ancestor generation time
1 1 NA 1 0.0000000
2 2 1 2 21.5834705
3 3 1 2 0.3939008
4 4 2 3 21.6595273

---

Code
tail(tree_sim_raw)
Output

< tree tail >

chain_id sim_id ancestor generation
1 1 1 NA 1
2 2 1 NA 1
3 1 2 1 2
4 1 3 1 2

---

Code
tail(tree_sim_raw2)
Output

< tree tail >

chain_id sim_id ancestor generation time
92 9 19 8 4 9
109 6 19 8 5 12
93 9 20 9 4 9
110 6 20 9 5 12
94 9 21 9 4 9
111 6 21 9 5 12

18 changes: 18 additions & 0 deletions tests/testthat/test-checks.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
test_that("Checks work", {
expect_error(
check_offspring_valid(1),
"character string"
)
expect_error(
check_offspring_func_valid("rrpois"),
"does not exist"
)
expect_error(
check_serial_valid("a"),
"must be a function"
)
expect_error(
check_nchains_valid(1.1),
"less than"
)
})
Loading