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

Tests on travis failing #104

Closed
zkamvar opened this issue Jun 3, 2019 · 7 comments
Closed

Tests on travis failing #104

zkamvar opened this issue Jun 3, 2019 · 7 comments
Labels

Comments

@zkamvar
Copy link
Member

zkamvar commented Jun 3, 2019

Epicontacts currently has a test failing on travis that doesn't look like a fluke:

https://travis-ci.org/reconhub/epicontacts/jobs/540650748#L1345-L1357

tests in ‘tests/testthat.R’ failed.
Last 13 lines of output:
  4: eval_bare(get_expr(quo), get_env(quo))
  5: zz[k = nocoords]
  6: `[.epicontacts`(zz, k = nocoords)
  7: data.frame(c(x$linelist[1], x$linelist[-1][k]), stringsAsFactors = FALSE)
  8: x$linelist[-1][k]
  9: `[.data.frame`(x$linelist[-1], k)
  10: stop("undefined columns selected")
  
  ══ testthat results  ═══════════════════════════════════════════════════════════
  OK: 141 SKIPPED: 3 WARNINGS: 1 FAILED: 2
  1. Failure: Returns epicontacts object subsetted correctly (@test_subset.epicontacts.R#115) 
  2. Error: Returns epicontacts object subsetted correctly (@test_subset.epicontacts.R#119) 
  
  Error: testthat unit tests failed
@zkamvar
Copy link
Member Author

zkamvar commented Jun 3, 2019

I believe the culprit was 4492006 since subset.epicontacts() relies on subset_clusters_by_id()

@zkamvar
Copy link
Member Author

zkamvar commented Jun 3, 2019

I think the issue here is that the subset data contains a row with missing values in the linelist

@finlaycampbell
Copy link
Collaborator

This looks like previously buggy behaviour that was fixed in the update. The command z[k = nocoords] should only be subsetting columns, but the saved, subsetted reference linelist has 12 rows whereas the original linelist has 13. In the current version both the pre-subsetted and post-subsetted linelists have 13 rows. I'd suggest overwriting rds/z.rds with the new output, as this gives the expect output.

@zkamvar
Copy link
Member Author

zkamvar commented Jun 6, 2019

As I mentioned in #105 (comment), I don't think this is an issue where we can simply update the output.

@nistara, I believe 4492006 may have caused some tests to fail on travis (see #104). They fail because the contacts list now has 13 rows, an extra column, and the dates have changed to numeric values (see below). Can you write a test for what you should expect to happen from the subset_clusters_by_id() function and then fix the issue?

library(epicontacts)
ebola_sim <- outbreaks::ebola_sim
x <- make_epicontacts(ebola_sim$linelist,
                      ebola_sim$contacts,
                      id = "case_id",
                      to = "case_id", from = "infector",
                      directed = FALSE)

dates <- as.Date(c("2014-04-08","2015-03-28"))


id <- names(which.max(get_degree(x, "out")))
z <- thin(subset(x, cluster_id = id), 2)
nocoords <- grep("(lat|lon)", names(z$linelist), perl = TRUE, invert = TRUE) - 1
z
#> 
#> /// Epidemiological Contacts //
#> 
#>   // class: epicontacts
#>   // 13 cases in linelist; 12 contacts;  non directed 
#> 
#>   // linelist
#> 
#> # A tibble: 13 x 12
#>    id    generation date_of_infecti… date_of_onset date_of_hospita…
#>    <chr>      <int>            <dbl>         <dbl>            <dbl>
#>  1 a6c6…          5            16226         16237            16239
#>  2 e4be…          6            16238         16243            16246
#>  3 e278…          7            16245         16252            16261
#>  4 916d…          6            16238         16264            16269
#>  5 4c10…          7            16268         16271            16271
#>  6 1f16…          7            16266         16277            16277
#>  7 c259…          7            16265         16275            16281
#>  8 8188…          7            16267         16284            16285
#>  9 ee65…          7            16268         16282            16288
#> 10 9f0c…          8            16276         16289            16290
#> 11 8863…          9            16290         16300            16302
#> 12 6ca9…          7            16267         16297            16306
#> 13 3ff1…         NA               NA            NA               NA
#> # … with 7 more variables: date_of_outcome <dbl>, outcome <chr>,
#> #   gender <chr>, hospital <chr>, lon <dbl>, lat <dbl>, id.1 <chr>
#> 
#>   // contacts
#> 
#> # A tibble: 12 x 3
#>    from   to     source 
#>    <chr>  <chr>  <chr>  
#>  1 a6c614 3ff1bc funeral
#>  2 a6c614 e4bee8 other  
#>  3 e4bee8 e27816 other  
#>  4 a6c614 916d0a other  
#>  5 916d0a 4c1040 other  
#>  6 916d0a 1f1620 other  
#>  7 916d0a c2595d other  
#>  8 916d0a 8188cd other  
#>  9 916d0a ee65e4 other  
#> 10 c2595d 9f0c37 other  
#> 11 9f0c37 88632e other  
#> 12 916d0a 6ca927 other
z$linelist
#>        id generation date_of_infection date_of_onset
#> 1  a6c614          5             16226         16237
#> 2  e4bee8          6             16238         16243
#> 3  e27816          7             16245         16252
#> 4  916d0a          6             16238         16264
#> 5  4c1040          7             16268         16271
#> 6  1f1620          7             16266         16277
#> 7  c2595d          7             16265         16275
#> 8  8188cd          7             16267         16284
#> 9  ee65e4          7             16268         16282
#> 10 9f0c37          8             16276         16289
#> 11 88632e          9             16290         16300
#> 12 6ca927          7             16267         16297
#> 13 3ff1bc         NA                NA            NA
#>    date_of_hospitalisation date_of_outcome outcome gender
#> 1                    16239           16247 Recover      f
#> 2                    16246              NA    <NA>      f
#> 3                    16261           16264 Recover      m
#> 4                    16269              NA    <NA>      f
#> 5                    16271              NA Recover      f
#> 6                    16277           16284   Death      f
#> 7                    16281           16322 Recover      m
#> 8                    16285           16311 Recover      f
#> 9                    16288           16289   Death      m
#> 10                   16290           16295   Death      f
#> 11                   16302           16307 Recover      m
#> 12                   16306           16313 Recover      m
#> 13                      NA              NA    <NA>   <NA>
#>              hospital       lon      lat   id.1
#> 1               other -13.21907 8.477376 a6c614
#> 2               other -13.22992 8.478471 e4bee8
#> 3  Connaught Hospital -13.24715 8.466236 e27816
#> 4               other -13.21633 8.480811 916d0a
#> 5               other -13.23596 8.477045 4c1040
#> 6               other -13.21373 8.468914 1f1620
#> 7   Military Hospital -13.26345 8.464106 c2595d
#> 8  Connaught Hospital -13.26120 8.463342 8188cd
#> 9  Connaught Hospital -13.23375 8.470376 ee65e4
#> 10              other -13.22357 8.483618 9f0c37
#> 11               <NA> -13.25422 8.460642 88632e
#> 12  Military Hospital -13.23645 8.468757 6ca927
#> 13               <NA>        NA       NA 3ff1bc

Created on 2019-06-06 by the reprex package (v0.3.0)

@zkamvar
Copy link
Member Author

zkamvar commented Jun 6, 2019

Note that the extra row here has the ID "3ff1bc"... which doesn't appear to exist in the linelist:

grep("3ff1bc", outbreaks::ebola_sim$linelist$case_id)
#> integer(0)

Created on 2019-06-06 by the reprex package (v0.3.0)

@zkamvar zkamvar added the bug label Jun 6, 2019
@finlaycampbell
Copy link
Collaborator

Ah soz you're right, good catch.
OK I've just pushed a potential fix to 7f5f401 and added a bunch of tests that test the function is actually doing what it's supposed to, i.e. returning all linelist and contact elements associated with the cluster a given ID belongs to.

@zkamvar zkamvar mentioned this issue Jun 6, 2019
@finlaycampbell
Copy link
Collaborator

Fixed as of f3463b6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants