Skip to content

Commit

Permalink
Covid19Mirai 2.8.1 (#223)
Browse files Browse the repository at this point in the history
* Bugfix/221 test map in continent (#222)
* Adjusted test
* ### Covid19Mirai 2.8.1
- Fixed tests (#221)
  • Loading branch information
GuidoMaggio authored Oct 17, 2022
1 parent dadf845 commit a3eb36e
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ rsconnect
deploy
library
local
.c
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: Covid19Mirai
Title: Covid-19 Data Analysis
Version: 2.8.0
Version: 2.8.1
Authors@R:
c(person("Riccardo", "Porreca", role = ("aut"),
email = "riccardo.porreca@mirai-solutions.com"),
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### Covid19Mirai 2.8.1
- Fixed tests (#221)

### Covid19Mirai 2.8.0
- updated to Covid19datahub 3.0.2 (#217)

Expand Down
2 changes: 1 addition & 1 deletion R/mod_map_calc_continent.R
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ legend_fun <- function(x, var){
else
val = log(seq(1,exp(max(bin)), length = 5000))
dat = val
suf = ifelse(grepl("1M", var)," over 1M", " cases")
suf = ifelse(grepl("1M", var)," over 1M", "")
.round_val = function(x){
if (any(x<0, na.rm = TRUE)){
y = rep(NA,length(x))
Expand Down
Binary file modified inst/datahub/DATA.rds
Binary file not shown.
Binary file modified inst/datahub/Selected_Country.rds
Binary file not shown.
Binary file modified inst/datahub/Top_Countries.rds
Binary file not shown.
12 changes: 6 additions & 6 deletions tests/testthat/test-get-datahub.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ if (FALSE) {
##############
# test last week on swiss data



test_that("get_datahub lev = 2 Swiss is ok", {
data_ch2 = get_timeseries_by_contagion_day_data(data_ch2)
orig_data_aggregate_ch2 = build_data_aggr(data_ch2)
Expand All @@ -47,6 +45,11 @@ test_that("get_datahub lev = 2 Swiss is ok", {
add_growth_death_rate()
orig_data_aggregate_today_ch2_today = orig_data_aggregate_ch2_today %>%
left_join(lw_orig_data_aggregate_ch2 %>% select(-population))
# no NAs
expect_equal(sum(sapply(orig_data_aggregate_today_ch2_today, is.na)), 0)
check_data(data_ch2)
check_data(orig_data_aggregate_ch2)
check_data(orig_data_aggregate_today_ch2_today)
})

# French data give always problems
Expand Down Expand Up @@ -98,7 +101,7 @@ test_that("test for missing dates and today data", {
expect_true(names(table(df$lagdate))== "1")

df = data %>% filter(date %in% tail(date,1)) %>% select(Country.Region, date, new_confirmed)
expect_true(sum(df$new_confirmed) > 0) # there are data
expect_true(sum(df$new_confirmed) != 0) # there are data (there could be negatives)

})
test_that("test for missing or duplicated countries", {
Expand Down Expand Up @@ -132,7 +135,6 @@ test_that("test pop_data and build_data_aggr returns expected format", {
# some countries seem now to be among those with no continent. To be fixed
#expect_false(any(unique(data$Country.Region) %in% na.cnt))


orig_data_aggregate <- build_data_aggr(data, pop_data)

countrynames= unique(orig_data_aggregate$Country.Region)
Expand All @@ -157,7 +159,6 @@ test_that("test pop_data and build_data_aggr returns expected format", {
setdiff(mapdata$NAME, pop_data$Country.Region)
setdiff(pop_data$Country.Region, mapdata$NAME)


.align_map_pop <- function(map,pop) {
tmp = map@data[,c("NAME","CONTINENT")] %>%
merge(pop[,c("Country.Region","continent")], by.x = "NAME", by.y = "Country.Region", all.x = T, sort = FALSE, incomparables = NA)
Expand All @@ -180,5 +181,4 @@ test_that("test pop_data and build_data_aggr returns expected format", {

expect_true(sum(is.na(pop_data$continent)) <= na.pop.data )


})

0 comments on commit a3eb36e

Please sign in to comment.