diff --git a/_delphi_utils_python/delphi_utils/archive.py b/_delphi_utils_python/delphi_utils/archive.py index 7c0e8be06..84f22f03d 100644 --- a/_delphi_utils_python/delphi_utils/archive.py +++ b/_delphi_utils_python/delphi_utils/archive.py @@ -104,7 +104,8 @@ def run_module(archive_type: str, Parameters ---------- archive_type: str - Type of ArchiveDiffer to run. Must be one of ["git", "s3"] which correspond to `GitArchiveDiffer` and `S3ArchiveDiffer`, respectively. + Type of ArchiveDiffer to run. Must be one of ["git", "s3"] which correspond to + `GitArchiveDiffer` and `S3ArchiveDiffer`, respectively. cache_dir: str The directory for storing most recent archived/uploaded CSVs to start diffing from. export_dir: str @@ -351,7 +352,7 @@ def update_cache(self): self._cache_updated = True - def archive_exports(self, + def archive_exports(self, # pylint: disable=arguments-differ exported_files: Files, update_cache: bool = True, update_s3: bool = True diff --git a/_delphi_utils_python/delphi_utils/export.py b/_delphi_utils_python/delphi_utils/export.py index 47f4a7604..b6bd041c4 100644 --- a/_delphi_utils_python/delphi_utils/export.py +++ b/_delphi_utils_python/delphi_utils/export.py @@ -1,3 +1,4 @@ +"""Export data in the format expected by the Delphi API.""" # -*- coding: utf-8 -*- from datetime import datetime from os.path import join diff --git a/_delphi_utils_python/delphi_utils/geomap.py b/_delphi_utils_python/delphi_utils/geomap.py index 25af29a0b..0d6da3c28 100644 --- a/_delphi_utils_python/delphi_utils/geomap.py +++ b/_delphi_utils_python/delphi_utils/geomap.py @@ -9,7 +9,7 @@ - remove deprecated functions once integration into JHU and Quidel is refactored see: https://github.com/cmu-delphi/covidcast-indicators/issues/283 """ - +# pylint: disable=too-many-lines from os.path import join import warnings import pkg_resources @@ -41,7 +41,7 @@ } -class GeoMapper: +class GeoMapper: # pylint: disable=too-many-public-methods """Geo mapping tools commonly used in Delphi. The GeoMapper class provides utility functions for translating between different @@ -301,7 +301,7 @@ def add_geocode( df[from_col] = df[from_col].astype(str) # Assuming that the passed-in records are all United States data, at the moment - if (from_code, new_code) in [("fips", "nation"), ("zip", "nation")]: + if (from_code, new_code) in [("fips", "nation"), ("zip", "nation")]: # pylint: disable=no-else-return df[new_col] = df[from_col].apply(lambda x: "us") return df elif new_code == "nation": @@ -724,7 +724,7 @@ def convert_state_code_to_state_id( ) state_table = self._load_crosswalk(from_code="state", to_code="state") - state_table = state_table[["state_code", "state_id"]].rename( + state_table = state_table[["state_code", "state_id"]].rename( # pylint: disable=unsubscriptable-object columns={"state_id": state_id_col} ) data = data.copy() @@ -796,7 +796,7 @@ def convert_zip_to_hrr(self, data, zip_col="zip", hrr_col="hrr"): return data def convert_zip_to_msa( - self, data, zip_col="zip", msa_col="msa", date_col="date", count_cols=None + self, data, zip_col="zip", date_col="date", count_cols=None ): """DEPRECATED.""" warnings.warn( @@ -828,7 +828,6 @@ def zip_to_msa( data = self.convert_zip_to_msa( data, zip_col=zip_col, - msa_col=msa_col, date_col=date_col, count_cols=count_cols, ) diff --git a/_delphi_utils_python/delphi_utils/smooth.py b/_delphi_utils_python/delphi_utils/smooth.py index 98d7f9723..9949b1262 100644 --- a/_delphi_utils_python/delphi_utils/smooth.py +++ b/_delphi_utils_python/delphi_utils/smooth.py @@ -18,7 +18,7 @@ import pandas as pd -class Smoother: +class Smoother: # pylint: disable=too-many-instance-attributes """Smoother class. This is the smoothing utility class. This class holds the parameter settings for its smoother @@ -78,8 +78,8 @@ class Smoother: Methods ---------- smooth: np.ndarray or pd.Series - Takes a 1D signal and returns a smoothed version. The input and the output have the same - length and type. + Takes a 1D signal and returns a smoothed version. + The input and the output have the same length and type. Example Usage ------------- @@ -260,20 +260,21 @@ def left_gauss_linear_smoother(self, signal): ) n = len(signal) signal_smoothed = np.zeros_like(signal) - A = np.vstack([np.ones(n), np.arange(n)]).T # the regression design matrix + # A is the regression design matrix + A = np.vstack([np.ones(n), np.arange(n)]).T # pylint: disable=invalid-name for idx in range(n): weights = np.exp( -((np.arange(idx + 1) - idx) ** 2) / self.gaussian_bandwidth ) - AwA = np.dot(A[: (idx + 1), :].T * weights, A[: (idx + 1), :]) - Awy = np.dot( + AwA = np.dot(A[: (idx + 1), :].T * weights, A[: (idx + 1), :]) # pylint: disable=invalid-name + Awy = np.dot( # pylint: disable=invalid-name A[: (idx + 1), :].T * weights, signal[: (idx + 1)].reshape(-1, 1) ) try: beta = np.linalg.solve(AwA, Awy) signal_smoothed[idx] = np.dot(A[: (idx + 1), :], beta)[-1] except np.linalg.LinAlgError: - signal_smoothed[idx] = signal[idx] if self.impute else np.nan + signal_smoothed[idx] = signal[idx] if self.impute else np.nan # pylint: disable=using-constant-test if self.minval is not None: signal_smoothed[signal_smoothed <= self.minval] = self.minval return signal_smoothed @@ -336,7 +337,7 @@ def savgol_coeffs(self, nl, nr): if nr > 0: raise warnings.warn("The filter is no longer causal.") - A = np.vstack( + A = np.vstack( # pylint: disable=invalid-name [np.arange(nl, nr + 1) ** j for j in range(self.poly_fit_degree + 1)] ).T @@ -380,7 +381,7 @@ def savgol_smoother(self, signal): # - shortened_window (default) applies savgol with a smaller window to do the fit # - identity keeps the original signal (doesn't smooth) # - nan writes nans - if self.boundary_method == "shortened_window": + if self.boundary_method == "shortened_window": # pylint: disable=no-else-return for ix in range(len(self.coeffs)): if ix == 0: signal_smoothed[ix] = signal[ix] diff --git a/_delphi_utils_python/delphi_utils/utils.py b/_delphi_utils_python/delphi_utils/utils.py index c6023e4a4..8de61aa37 100644 --- a/_delphi_utils_python/delphi_utils/utils.py +++ b/_delphi_utils_python/delphi_utils/utils.py @@ -1,3 +1,4 @@ +"""Read parameter files containing configuration information.""" # -*- coding: utf-8 -*- from json import load from os.path import exists