Skip to content

Commit c47808b

Browse files
authored
Merge pull request #1460 from cmu-delphi/release/indicators_v0.2.20_utils_v0.2.9
Release covidcast-indicators 0.2.20
2 parents 5ed605c + df7d0b4 commit c47808b

File tree

17 files changed

+99
-42
lines changed

17 files changed

+99
-42
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.2.19
2+
current_version = 0.2.20
33
commit = True
44
message = chore: bump covidcast-indicators to {new_version}
55
tag = False

.github/workflows/python-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
if: github.event.pull_request.draft == false
1717
strategy:
1818
matrix:
19-
packages: [_delphi_utils_python, changehc, claims_hosp, combo_cases_and_deaths, covid_act_now, doctor_visits, google_symptoms, hhs_hosp, hhs_facilities, jhu, nchs_mortality, nowcast, quidel, quidel_covidtest, safegraph_patterns, sir_complainsalot, usafacts]
19+
packages: [_delphi_utils_python, changehc, claims_hosp, combo_cases_and_deaths, doctor_visits, google_symptoms, hhs_hosp, hhs_facilities, jhu, nchs_mortality, nowcast, quidel, quidel_covidtest, safegraph_patterns, sir_complainsalot, usafacts]
2020
defaults:
2121
run:
2222
working-directory: ${{ matrix.packages }}

Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
- Keep in sync with '.github/workflows/python-ci.yml'.
1010
- TODO: #527 Get this list automatically from python-ci.yml at runtime.
1111
*/
12-
def indicator_list = ["changehc", "claims_hosp", "covid_act_now", "facebook", "google_symptoms", "hhs_hosp", "jhu", "nchs_mortality", "quidel", "quidel_covidtest", "safegraph_patterns", "sir_complainsalot", "usafacts"]
12+
def indicator_list = ["changehc", "claims_hosp", "facebook", "google_symptoms", "hhs_hosp", "jhu", "nchs_mortality", "quidel", "quidel_covidtest", "safegraph_patterns", "sir_complainsalot", "usafacts"]
1313
def build_package = [:]
1414
def deploy_staging = [:]
1515
def deploy_production = [:]

_delphi_utils_python/.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.2.8
2+
current_version = 0.2.9
33
commit = True
44
message = chore: bump delphi_utils to {new_version}
55
tag = False

_delphi_utils_python/delphi_utils/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
from .nancodes import Nans
1616
from .weekday import Weekday
1717

18-
__version__ = "0.2.8"
18+
__version__ = "0.2.9"

_delphi_utils_python/delphi_utils/validator/datafetcher.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,10 @@ def get_geo_signal_combos(data_source):
111111
Cross references based on combinations reported available by COVIDcast metadata.
112112
"""
113113
# Maps data_source name with what's in the API, lists used in case of multiple names
114+
# pylint: disable=fixme
115+
# TODO: Extract this mapping from meta response instead of hard-coding
116+
# https://github.com/cmu-delphi/covidcast-indicators/issues/1457
114117
source_signal_mappings = {
115-
'chng': ['chng-cli', 'chng-covid'],
116118
'indicator-combination': ['indicator-combination-cases-deaths'],
117119
'quidel': ['quidel-covid-ag'],
118120
'safegraph': ['safegraph-weekly']

_delphi_utils_python/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
setup(
2828
name="delphi_utils",
29-
version="0.2.8",
29+
version="0.2.9",
3030
description="Shared Utility Functions for Indicators",
3131
long_description=long_description,
3232
long_description_content_type="text/markdown",

_delphi_utils_python/tests/validator/test_datafetcher.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ def test_make_date_filter(self):
2121
assert not date_filter(FILENAME_REGEX.match("20200620_a_b.csv"))
2222
assert not date_filter(FILENAME_REGEX.match("202006_a_b.csv"))
2323

24+
# pylint: disable=fixme
25+
# TODO: mock out the advanced meta endpoint /covidcast/meta as well
26+
# https://github.com/cmu-delphi/covidcast-indicators/issues/1456
2427
@mock.patch("covidcast.metadata")
2528
def test_get_geo_signal_combos(self, mock_metadata):
2629
"""Test that the geo signal combos are correctly pulled from the covidcast metadata."""

ansible/templates/sir_complainsalot-params-prod.json.j2

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,6 @@
102102
"max_age":16,
103103
"maintainers": []
104104
},
105-
"covid-act-now": {
106-
"max_age":9,
107-
"maintainers": []
108-
},
109105
"hhs": {
110106
"max_age":8,
111107
"maintainers": []

facebook/delphiFacebook/R/contingency_indicators.R

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,17 @@ get_aggs <- function() {
7373
## Mask wearing and distancing
7474
"pct_wearing_mask_5d", "c_mask_often", compute_binary, jeffreys_binary,
7575
"pct_wearing_mask_7d", "c_mask_often_7d", compute_binary, jeffreys_binary,
76+
"pct_others_masked", "c_others_masked", compute_binary, jeffreys_binary,
7677
"pct_others_masked_public", "c_others_masked_public", compute_binary, jeffreys_binary,
7778
"pct_others_distanced_public", "c_others_distanced_public", compute_binary, jeffreys_binary,
7879

7980
"pct_cli", "hh_p_cli", compute_household_binary, jeffreys_count,
8081
"pct_ili", "hh_p_ili", compute_household_binary, jeffreys_count,
8182
"pct_hh_cmnty_cli", "hh_community_yes", compute_binary, jeffreys_binary,
83+
"pct_nohh_cmnty_cli", "community_yes", compute_binary, jeffreys_binary,
8284
"pct_direct_contact", "c_direct_contact", compute_binary, jeffreys_binary,
85+
"pct_avoid_contact", "c_avoid_contact", compute_binary, jeffreys_binary,
86+
"pct_avoid_contact_7d", "c_avoid_contact_7d", compute_binary, jeffreys_binary,
8387

8488
# symptoms
8589
"pct_symp_fever", "symp_fever", compute_binary, jeffreys_binary,
@@ -303,8 +307,6 @@ get_aggs <- function() {
303307
"pct_race_treated_fairly_healthcare", "b_race_treated_fairly_healthcare", compute_binary, jeffreys_binary,
304308
"pct_delayed_care_cost", "b_delayed_care_cost", compute_binary, jeffreys_binary,
305309

306-
"pct_worried_catch_covid", "mh_worried_catch_covid", compute_binary, jeffreys_binary,
307-
308310
# topics want to learn about
309311
"pct_want_info_covid_treatment", "i_want_info_covid_treatment", compute_binary, jeffreys_binary,
310312
"pct_want_info_vaccine_access", "i_want_info_vaccine_access", compute_binary, jeffreys_binary,
@@ -355,6 +357,8 @@ get_aggs <- function() {
355357
"pct_anxious_7d", "mh_anxious_7d", compute_binary, jeffreys_binary,
356358
"pct_depressed_7d", "mh_depressed_7d", compute_binary, jeffreys_binary,
357359
"pct_felt_isolated_7d", "mh_isolated_7d", compute_binary, jeffreys_binary,
360+
# wave 11
361+
"pct_worried_catch_covid", "mh_worried_catch_covid", compute_binary, jeffreys_binary,
358362

359363
# travel outside state
360364
# pre-wave 10
@@ -420,7 +424,11 @@ get_aggs <- function() {
420424
"pct_vaccine_barrier_type_tried", "v_vaccine_barrier_type_tried", compute_binary, jeffreys_binary,
421425
"pct_vaccine_barrier_none_tried", "v_vaccine_barrier_none_tried", compute_binary, jeffreys_binary,
422426
"pct_vaccine_barrier_appointment_location_tried", "v_vaccine_barrier_appointment_location_tried", compute_binary, jeffreys_binary,
423-
"pct_vaccine_barrier_other_tried", "v_vaccine_barrier_other_tried", compute_binary, jeffreys_binary
427+
"pct_vaccine_barrier_other_tried", "v_vaccine_barrier_other_tried", compute_binary, jeffreys_binary,
428+
429+
# schooling
430+
"pct_inperson_school_fulltime", "s_inperson_school_fulltime", compute_binary, jeffreys_binary,
431+
"pct_inperson_school_parttime", "s_inperson_school_parttime", compute_binary, jeffreys_binary
424432
)
425433

426434
aggs <- create_aggs_product(regions, groups, indicators)

facebook/delphiFacebook/R/contingency_variables.R

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,36 @@ code_behaviors <- function(input_data, wave) {
10401040
} else {
10411041
input_data$c_direct_contact <- NA
10421042
}
1043+
1044+
# avoid_contact
1045+
# Percentage of respondents that have reported having intentionally avoided
1046+
# contact with other people all or most of the time
1047+
# 1 = all of the time, 2 = most of the time, 3 = some of the time,
1048+
# 4 = none of the time
1049+
if ("C7" %in% names(input_data)) {
1050+
input_data$c_avoid_contact <- case_when(
1051+
input_data$C7 %in% c(1, 2) ~ 1,
1052+
input_data$C7 %in% c(3, 4) ~ 0,
1053+
TRUE ~ NA_real_
1054+
)
1055+
} else {
1056+
input_data$c_avoid_contact <- NA_real_
1057+
}
1058+
1059+
# avoid_contact_7d
1060+
# Percentage of respondents that have reported having intentionally avoided
1061+
# contact with other people all or most of the time in the last 7 days
1062+
# 1 = all of the time, 2 = most of the time, 3 = some of the time,
1063+
# 4 = a little of the time, 5 = none of the time
1064+
if ("C7a" %in% names(input_data)) {
1065+
input_data$c_avoid_contact_7d <- case_when(
1066+
input_data$C7a %in% c(1, 2) ~ 1,
1067+
input_data$C7a %in% c(3, 4, 5) ~ 0,
1068+
TRUE ~ NA_real_
1069+
)
1070+
} else {
1071+
input_data$c_avoid_contact_7d <- NA_real_
1072+
}
10431073

10441074
return(input_data)
10451075
}

facebook/delphiFacebook/R/variables.R

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
#' @return list of same length, each entry of which is a vector of selected
1515
#' options
1616
split_options <- function(column) {
17-
return(strsplit(column, ",", fixed = TRUE))
17+
if ( any(!is.na(column)) ) {
18+
return(strsplit(column, ",", fixed = TRUE))
19+
} else {
20+
return(rep(list(NA_character_), length(column)))
21+
}
1822
}
1923

2024
#' Test if a specific selection is selected
@@ -648,16 +652,8 @@ code_vaccines <- function(input_data, wave) {
648652
if ( all(c("V15a", "V15b") %in% names(input_data)) ) {
649653
# introduced in Wave 11
650654
vaccine_barriers <- coalesce(input_data$V15a, input_data$V15b)
651-
652-
# If the entire column is NA, ifelse() results in a logical vector, not a
653-
# character vector, which confuses split_options; since the result should be
654-
# NA anyway
655-
vaccine_barriers <- as.character(
656-
ifelse(vaccine_barriers == "13", NA_character_, vaccine_barriers)
657-
)
658-
if (any(!is.na(vaccine_barriers))) {
659-
vaccine_barriers <- split_options(vaccine_barriers)
660-
}
655+
vaccine_barriers <- ifelse(vaccine_barriers == "13", NA_character_, vaccine_barriers)
656+
vaccine_barriers <- split_options(vaccine_barriers)
661657

662658
input_data$v_vaccine_barrier_eligible <- is_selected(vaccine_barriers, "1")
663659
input_data$v_vaccine_barrier_no_appointments <- is_selected(vaccine_barriers, "2")
@@ -677,7 +673,7 @@ code_vaccines <- function(input_data, wave) {
677673
} else if ( all(c("V15c", "V15b") %in% names(input_data)) ) {
678674
# V15c introduced in Wave 12, replacing V15a with clarified wording.
679675
vaccine_barriers <- coalesce(input_data$V15c, input_data$V15b)
680-
vaccine_barriers <- ifelse(vaccine_barriers == "13", NA, vaccine_barriers)
676+
vaccine_barriers <- ifelse(vaccine_barriers == "13", NA_character_, vaccine_barriers)
681677
vaccine_barriers <- split_options(vaccine_barriers)
682678

683679
input_data$v_vaccine_barrier_eligible <- is_selected(vaccine_barriers, "1")
@@ -769,15 +765,8 @@ code_vaccines <- function(input_data, wave) {
769765

770766
if ( "V15b" %in% names(input_data) ) {
771767
# introduced in Wave 11
772-
# If the entire column is NA, ifelse() results in a logical vector, not a
773-
# character vector, which confuses split_options; since the result should be
774-
# NA anyway
775-
vaccine_barriers <- as.character(
776-
ifelse(input_data$V15b == "13", NA, input_data$V15b)
777-
)
778-
if (any(!is.na(vaccine_barriers))) {
779-
vaccine_barriers <- split_options(vaccine_barriers)
780-
}
768+
vaccine_barriers <- ifelse(input_data$V15b == "13", NA_character_, input_data$V15b)
769+
vaccine_barriers <- split_options(vaccine_barriers)
781770

782771
input_data$v_vaccine_barrier_eligible_tried <- is_selected(vaccine_barriers, "1")
783772
input_data$v_vaccine_barrier_no_appointments_tried <- is_selected(vaccine_barriers, "2")

facebook/delphiFacebook/src/RcppExports.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55

66
using namespace Rcpp;
77

8+
#ifdef RCPP_USE_GLOBAL_ROSTREAM
9+
Rcpp::Rostream<true>& Rcpp::Rcout = Rcpp::Rcpp_cout_get();
10+
Rcpp::Rostream<false>& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get();
11+
#endif
12+
813
// is_selected_cpp
914
LogicalVector is_selected_cpp(List responses, String target);
1015
RcppExport SEXP _delphiFacebook_is_selected_cpp(SEXP responsesSEXP, SEXP targetSEXP) {

facebook/delphiFacebook/unit-tests/testthat/test-variables.R

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@ library(testthat)
22

33
context("Testing response coding")
44

5+
test_that("split_options splits correctly", {
6+
expect_equal(split_options(c("1", "", "1,2")),
7+
list(c("1"), character(0), c("1", "2")))
8+
9+
# Input logical vector
10+
expect_equal(split_options(c(NA, NA, NA)),
11+
list(NA_character_, NA_character_, NA_character_))
12+
13+
# Input character vector
14+
expect_equal(split_options(c(NA_character_, NA_character_, NA_character_)),
15+
list(NA_character_, NA_character_, NA_character_))
16+
17+
expect_equal(split_options(c("", NA_character_, NA)),
18+
list(character(0), NA_character_, NA_character_))
19+
})
20+
521
test_that("is_selected handles selections correctly", {
622
expect_equal(is_selected(split_options(c("1", "", "1,2")), "1"),
723
c(TRUE, NA, TRUE))
@@ -18,6 +34,18 @@ test_that("is_selected handles selections correctly", {
1834
expect_equal(is_selected(split_options(c("4,54", "3,6,2,54", "5,4,45")),
1935
"54"),
2036
c(TRUE, TRUE, FALSE))
37+
38+
expect_equal(is_selected(c(NA, NA, NA), "14"),
39+
c(NA, NA, NA))
40+
41+
expect_equal(is_selected(c(NA_character_, NA_character_, NA_character_), "14"),
42+
c(NA, NA, NA))
43+
44+
expect_equal(is_selected(list(NA, NA, NA), "14"),
45+
c(NA, NA, NA))
46+
47+
expect_equal(is_selected(list(NA_character_, NA_character_, NA_character_), "14"),
48+
c(NA, NA, NA))
2149
})
2250

2351
test_that("activities items correctly coded", {

facebook/micro/monthly-archive.sh

100644100755
File mode changed.

facebook/qsf-tools/generate-codebook.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ add_qdf_to_codebook <- function(qdf,
350350
} else {
351351
codebook <- read_csv(path_to_codebook, col_types = cols(
352352
.default = col_character(),
353-
wave = col_integer(),
353+
wave = col_double(),
354354
variable = col_character(),
355355
replaces = col_character(),
356356
description = col_character(),
@@ -399,7 +399,7 @@ add_static_fields <- function(codebook,
399399
codebook <- bind_rows(codebook, static_fields) %>%
400400
filter(!(variable == "module" & wave < 11), # module field is only available for wave >= 11
401401
!(variable %in% c("wave", "UserLanguage", "fips") & wave < 4), # wave, UserLangauge, and fips fields are only available for wave >= 4
402-
!(variable == "w12_treatment" & wave == 12.5), # experimental arm field is only available for wave == 12.5
402+
!(variable == "w12_treatment" & wave != 12.5), # experimental arm field is only available for wave == 12.5
403403
variable != "Random_Number"
404404
)
405405

@@ -438,7 +438,7 @@ get_static_fields <- function(wave,
438438
add_qsf_to_codebook <- function(path_to_qsf, path_to_codebook) {
439439
qdf <- process_qsf(path_to_qsf)
440440
codebook <- add_qdf_to_codebook(qdf, path_to_codebook)
441-
write_excel_csv(codebook, path_to_codebook)
441+
write_excel_csv(codebook, path_to_codebook, quote="needed")
442442
}
443443

444444

sir_complainsalot/params.json.template

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,6 @@
101101
"max_age":16,
102102
"maintainers": []
103103
},
104-
"covid-act-now": {
105-
"max_age":9,
106-
"maintainers": []
107-
},
108104
"hhs": {
109105
"max_age":8,
110106
"maintainers": []

0 commit comments

Comments
 (0)