From f061ec8a56970d837749162af02fc5ea12ccc928 Mon Sep 17 00:00:00 2001 From: chinandrew Date: Wed, 21 Oct 2020 09:12:30 -0700 Subject: [PATCH 1/2] Remove wildcard imports and fix some linting --- .../constants.py | 2 +- .../delphi_combo_cases_and_deaths/run.py | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/combo_cases_and_deaths/delphi_combo_cases_and_deaths/constants.py b/combo_cases_and_deaths/delphi_combo_cases_and_deaths/constants.py index 26539522c..2392366bb 100644 --- a/combo_cases_and_deaths/delphi_combo_cases_and_deaths/constants.py +++ b/combo_cases_and_deaths/delphi_combo_cases_and_deaths/constants.py @@ -18,4 +18,4 @@ "state", "msa", "hrr", -] \ No newline at end of file +] diff --git a/combo_cases_and_deaths/delphi_combo_cases_and_deaths/run.py b/combo_cases_and_deaths/delphi_combo_cases_and_deaths/run.py index 165524bfb..760d3fde8 100755 --- a/combo_cases_and_deaths/delphi_combo_cases_and_deaths/run.py +++ b/combo_cases_and_deaths/delphi_combo_cases_and_deaths/run.py @@ -6,17 +6,17 @@ is only used for visualization. It sources Puerto Rico from jhu-csse and everything else from usa-facts. """ -from datetime import date, timedelta, datetime -from itertools import product import re import sys +from datetime import date, timedelta, datetime +from itertools import product import covidcast import pandas as pd +from delphi_utils import read_params -from delphi_utils import read_params, create_export_csv -from .constants import * -from .handle_wip_signal import * +from .constants import METRICS, SMOOTH_TYPES, SENSORS, GEO_RESOLUTIONS +from .handle_wip_signal import add_prefix def check_not_none(data_frame, label, date_range): @@ -119,12 +119,12 @@ def run_module(): "Invalid date_range parameter. Please choose from (new, all, yyyymmdd-yyyymmdd).") try: date1 = datetime.strptime(params['date_range'][:8], '%Y%m%d').date() - except ValueError: - raise ValueError("Invalid date_range parameter. Please check the first date.") + except ValueError as exc: + raise ValueError("Invalid date_range parameter. Please check the first date.") from exc try: date2 = datetime.strptime(params['date_range'][-8:], '%Y%m%d').date() - except ValueError: - raise ValueError("Invalid date_range parameter. Please check the second date.") + except ValueError as exc: + raise ValueError("Invalid date_range parameter. Please check the second date.") from exc #The the valid start date if date1 < params['export_start_date']: @@ -149,4 +149,3 @@ def run_module(): df[df["timestamp"] == date_][["geo_id", "val", "se", "sample_size", ]].to_csv( f"{export_dir}/{export_fn}", index=False, na_rep="NA" ) - From 9b624841b6cdb565e20b46e7634f7f26f91677ba Mon Sep 17 00:00:00 2001 From: chinandrew Date: Wed, 21 Oct 2020 09:16:15 -0700 Subject: [PATCH 2/2] Remove wildcards for tests --- combo_cases_and_deaths/tests/test_run.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/combo_cases_and_deaths/tests/test_run.py b/combo_cases_and_deaths/tests/test_run.py index 3cdc4929c..5b11d5305 100644 --- a/combo_cases_and_deaths/tests/test_run.py +++ b/combo_cases_and_deaths/tests/test_run.py @@ -1,12 +1,10 @@ +import unittest from datetime import date from itertools import product -import pytest -import unittest -from delphi_combo_cases_and_deaths.run import extend_raw_date_range, sensor_signal +from delphi_combo_cases_and_deaths.constants import METRICS, SENSORS, SMOOTH_TYPES from delphi_combo_cases_and_deaths.handle_wip_signal import add_prefix -from delphi_utils import read_params -from delphi_combo_cases_and_deaths.constants import * +from delphi_combo_cases_and_deaths.run import extend_raw_date_range, sensor_signal def test_issue_dates():