Skip to content

Update makefiles to fix linting failures not failing #753

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

Merged
merged 3 commits into from
Jan 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 2 additions & 3 deletions _delphi_utils_python/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ install: venv
pip install -e .

lint:
. env/bin/activate; \
pylint $(dir); \
pydocstyle $(dir)
. env/bin/activate; pylint $(dir)
. env/bin/activate; pydocstyle $(dir)

test:
. env/bin/activate ;\
Expand Down
1 change: 0 additions & 1 deletion _delphi_utils_python/delphi_utils/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,4 @@ def create_export_csv(
if remove_null_samples:
export_df = export_df[export_df["sample_size"].notnull()]
export_df.to_csv(export_file, index=False, na_rep="NA")

return dates
6 changes: 4 additions & 2 deletions _delphi_utils_python/delphi_utils/geomap.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ def add_geocode(
df = df.copy()
from_col = from_code if from_col is None else from_col
new_col = new_code if new_col is None else new_col
assert from_col != new_col, f"Can't use the same column '{from_col}' for both from_col and to_col"
assert from_col != new_col, \
f"Can't use the same column '{from_col}' for both from_col and to_col"
state_codes = ["state_code", "state_id", "state_name"]

if not is_string_dtype(df[from_col]):
Expand All @@ -325,7 +326,8 @@ def add_geocode(
return df
elif new_code == "nation":
raise ValueError(
f"Conversion to the nation level is not supported from {from_code}; try fips, zip, or state_*"
f"Conversion to the nation level is not supported "
f"from {from_code}; try fips, zip, or state_*"
)

# state codes are all stored in one table
Expand Down
5 changes: 2 additions & 3 deletions _template_python/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ install: venv
pip install -e .

lint:
. env/bin/activate; \
pylint $(dir); \
pydocstyle $(dir)
. env/bin/activate; pylint $(dir)
. env/bin/activate; pydocstyle $(dir)

test:
. env/bin/activate ;\
Expand Down
5 changes: 2 additions & 3 deletions cdc_covidnet/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ install: venv
pip install -e .

lint:
. env/bin/activate; \
pylint $(dir); \
pydocstyle $(dir)
. env/bin/activate; pylint $(dir)
. env/bin/activate; pydocstyle $(dir)

test:
. env/bin/activate ;\
Expand Down
5 changes: 2 additions & 3 deletions changehc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ install: venv
pip install -e .

lint:
. env/bin/activate; \
pylint $(dir); \
pydocstyle $(dir)
. env/bin/activate; pylint $(dir)
. env/bin/activate; pydocstyle $(dir)

test:
. env/bin/activate ;\
Expand Down
5 changes: 2 additions & 3 deletions changehc/delphi_changehc/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,9 @@ def run_module():
su_inst.update_sensor(
data,
params["export_dir"]
)
)
logger.info("finished processing", geo = geo)

elapsed_time_in_seconds = round(time.time() - start_time, 2)
logger.info("Completed indicator run",
elapsed_time_in_seconds = elapsed_time_in_seconds)

6 changes: 2 additions & 4 deletions claims_hosp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ install: venv
pip install -e .

lint:
. env/bin/activate; \
pylint $(dir)
pylint $(dir); \
pydocstyle $(dir)
. env/bin/activate; pylint $(dir)
. env/bin/activate; pydocstyle $(dir)

test:
. env/bin/activate ;\
Expand Down
5 changes: 2 additions & 3 deletions combo_cases_and_deaths/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ install: venv
pip install -e .

lint:
. env/bin/activate; \
pylint $(dir); \
pydocstyle $(dir)
. env/bin/activate; pylint $(dir)
. env/bin/activate; pydocstyle $(dir)

test:
. env/bin/activate ;\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ 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"
)

elapsed_time_in_seconds = round(time.time() - start_time, 2)
logger.info("Completed indicator run",
elapsed_time_in_seconds = elapsed_time_in_seconds)
5 changes: 2 additions & 3 deletions covid_act_now/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ install: venv
pip install -e .

lint:
. env/bin/activate; \
pylint $(dir); \
pydocstyle $(dir)
. env/bin/activate; pylint $(dir)
. env/bin/activate; pydocstyle $(dir)

test:
. env/bin/activate ;\
Expand Down
4 changes: 2 additions & 2 deletions google_health/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ install: venv
pip install -e .

lint:
. env/bin/activate; \
pylint $(dir)
. env/bin/activate; pylint $(dir)
. env/bin/activate; pydocstyle $(dir)

test:
. env/bin/activate ;\
Expand Down
8 changes: 3 additions & 5 deletions google_symptoms/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ install: venv
pip install -e .

lint:
. env/bin/activate; \
pylint $(dir); \
pydocstyle $(dir)
. env/bin/activate; pylint $(dir)
. env/bin/activate; pydocstyle $(dir)

test:
. env/bin/activate ;\
(cd tests && ../env/bin/pytest --cov=$(dir) --cov-report=term-missing)
. env/bin/activate ; (cd tests && ../env/bin/pytest --cov=$(dir) --cov-report=term-missing)

clean:
rm -rf env
Expand Down
12 changes: 6 additions & 6 deletions google_symptoms/delphi_google_symptoms/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
This module should contain a function called `run_module`, that is executed
when the module is run with `python -m delphi_google_symptoms`.
"""
import time
from datetime import datetime
from itertools import product

import numpy as np
import time
from delphi_utils import (
read_params,
create_export_csv,
read_params,
create_export_csv,
geomap,
get_structured_logger
)

from .pull import pull_gs_data
from .geo import geo_map
from .constants import (METRICS, COMBINED_METRIC,
GEO_RESOLUTIONS, SMOOTHERS, SMOOTHERS_MAP)
from .geo import geo_map
from .pull import pull_gs_data


def run_module():
Expand Down Expand Up @@ -66,7 +66,7 @@ def run_module():
metric=metric.lower(),
geo_res=geo_res,
sensor=sensor_name)

if not exported_csv_dates.empty:
csv_export_count += exported_csv_dates.size
if not oldest_final_export_date:
Expand Down
5 changes: 2 additions & 3 deletions hhs_facilities/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ install: venv
pip install -e .

lint:
. env/bin/activate; \
pylint $(dir); \
pydocstyle $(dir)
. env/bin/activate; pylint $(dir)
. env/bin/activate; pydocstyle $(dir)

test:
. env/bin/activate ;\
Expand Down
5 changes: 2 additions & 3 deletions hhs_hosp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ install: venv
pip install -e .

lint:
. env/bin/activate; \
pylint $(dir); \
pydocstyle $(dir)
. env/bin/activate; pylint $(dir)
. env/bin/activate; pydocstyle $(dir)

test:
. env/bin/activate ;\
Expand Down
5 changes: 2 additions & 3 deletions jhu/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ install: venv
pip install -e .

lint:
. env/bin/activate; \
pylint $(dir); \
pydocstyle $(dir)
. env/bin/activate; pylint $(dir)
. env/bin/activate; pydocstyle $(dir)

test:
. env/bin/activate ;\
Expand Down
5 changes: 2 additions & 3 deletions nchs_mortality/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ install: venv
pip install -e .

lint:
. env/bin/activate; \
pylint $(dir); \
pydocstyle $(dir)
. env/bin/activate; pylint $(dir)
. env/bin/activate; pydocstyle $(dir)

test:
. env/bin/activate ;\
Expand Down
5 changes: 2 additions & 3 deletions nowcast/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ install: venv
pip install -e .

lint:
. env/bin/activate; \
pylint $(dir); \
pydocstyle $(dir) --match-dir '(?!nowcast_fusion)'
. env/bin/activate; pylint $(dir)
. env/bin/activate; pydocstyle $(dir) --match-dir '(?!nowcast_fusion)'

test:
. env/bin/activate ;\
Expand Down
5 changes: 2 additions & 3 deletions quidel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ install: venv
pip install -e .

lint:
. env/bin/activate; \
pylint $(dir); \
pydocstyle $(dir)
. env/bin/activate; pylint $(dir)
. env/bin/activate; pydocstyle $(dir)

test:
. env/bin/activate ;\
Expand Down
10 changes: 5 additions & 5 deletions quidel/delphi_quidel/data_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
def _prop_var(p, n):
"""
Calculate variance of proportion.

var(X/n) = 1/(n^2)var(X) = (npq)/(n^2) = pq/n
"""
return p * (1 - p) / n
Expand Down Expand Up @@ -64,7 +64,7 @@ def _slide_window_sum(arr, k):

def _geographical_pooling(tpooled_tests, tpooled_ptests, min_obs, max_borrow_obs):
"""
Calculate proportion of parent samples (tests) that must be "borrowed" in order to compute the statistic.
Calculate proportion of parent samples (tests) that must be "borrowed" to compute the statistic.

If there are no samples available in the parent, the borrow_prop is 0. If the parent does not
have enough samples, we return a borrow_prop of 1, and the fact that the
Expand Down Expand Up @@ -119,7 +119,7 @@ def _geographical_pooling(tpooled_tests, tpooled_ptests, min_obs, max_borrow_obs

def raw_positive_prop(positives, tests, min_obs):
"""
Calculate the proportion of positive tests for a single geographic location, without any temporal smoothing.
Calculate proportion of positive tests for a single location with no temporal smoothing.

If on any day t, tests[t] < min_obs, then we report np.nan.

Expand Down Expand Up @@ -172,7 +172,7 @@ def raw_positive_prop(positives, tests, min_obs):
def smoothed_positive_prop(positives, tests, min_obs, max_borrow_obs, pool_days,
parent_positives=None, parent_tests=None):
"""
Calculate the proportion of negative tests for a single geographic location, with temporal smoothing.
Calculate the proportion of negative tests for a single location with temporal smoothing.

For a given day t, if sum(tests[(t-pool_days+1):(t+1)]) < min_obs, then we
'borrow' min_obs - sum(tests[(t-pool_days+1):(t+1)]) observations from the
Expand Down Expand Up @@ -307,7 +307,7 @@ def raw_tests_per_device(devices, tests, min_obs):
def smoothed_tests_per_device(devices, tests, min_obs, max_borrow_obs, pool_days,
parent_devices=None, parent_tests=None):
"""
Calculate the ratio of tests per device for a single geographic location, with temporal smoothing.
Calculate the ratio of tests per device for a single location with temporal smoothing.

For a given day t, if sum(tests[(t-pool_days+1):(t+1)]) < min_obs, then we
'borrow' min_obs - sum(tests[(t-pool_days+1):(t+1)]) observations from the
Expand Down
9 changes: 6 additions & 3 deletions quidel/delphi_quidel/pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def read_historical_data():

def regulate_column_names(df, test_type):
"""
Regulate column names for flu_ag test data since Quidel changed their column names multiple times.
Regulate column names for flu_ag test data since Quidel changed the column names multiple times.

We want to finalize the column name list to be:
['SofiaSerNum', 'TestDate', 'Facility',
Expand Down Expand Up @@ -311,7 +311,7 @@ def check_intermediate_file(cache_dir, pull_start_dates):

def pull_quidel_data(params):
"""
Pull the quidel test data and decide whether to combine the new data with stored historical records in ./cache.
Pull new quidel test data and decide whether to combine it with historical records in ./cache.

Parameters:
params: dict
Expand Down Expand Up @@ -402,7 +402,10 @@ def check_export_end_date(input_export_end_dates, _end_date,
def check_export_start_date(export_start_dates, export_end_dates,
export_day_range):
"""
Update export_start_date according to the export_end_date so that it could be export_end_date - EXPORT_DAY_RANGE.
Update export_start_date according to the export_end_date.

Update export_start_date according to the export_end_date so that
it could be export_end_date - EXPORT_DAY_RANGE.

Parameters:
export_start_date: dict
Expand Down
11 changes: 6 additions & 5 deletions quidel/delphi_quidel/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,27 @@
This module should contain a function called `run_module`, that is executed
when the module is run with `python -m MODULE_NAME`.
"""
import time
from os.path import join

import pandas as pd
import time
from delphi_utils import (
read_params,
add_prefix,
create_export_csv,
get_structured_logger
)

from .constants import (END_FROM_TODAY_MINUS, EXPORT_DAY_RANGE,
GEO_RESOLUTIONS, SENSORS)
from .generate_sensor import (generate_sensor_for_states,
generate_sensor_for_other_geores)
from .geo_maps import geo_map
from .pull import (pull_quidel_data,
check_export_start_date,
check_export_end_date,
update_cache_file)
from .generate_sensor import (generate_sensor_for_states,
generate_sensor_for_other_geores)
from .constants import (END_FROM_TODAY_MINUS, EXPORT_DAY_RANGE,
GEO_RESOLUTIONS, SENSORS)


def run_module():
"""Run Quidel flu test module."""
Expand Down
5 changes: 2 additions & 3 deletions quidel_covidtest/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ install: venv
pip install -e .

lint:
. env/bin/activate; \
pylint $(dir); \
pydocstyle $(dir)
. env/bin/activate; pylint $(dir)
. env/bin/activate; pydocstyle $(dir)

test:
. env/bin/activate ;\
Expand Down
Loading