Skip to content

Commit 4f1548e

Browse files
committed
fix linting
1 parent 7e9e6cb commit 4f1548e

File tree

5 files changed

+20
-17
lines changed

5 files changed

+20
-17
lines changed

_delphi_utils_python/delphi_utils/archive.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ def run_module(archive_type: str,
104104
Parameters
105105
----------
106106
archive_type: str
107-
Type of ArchiveDiffer to run. Must be one of ["git", "s3"] which correspond to `GitArchiveDiffer` and `S3ArchiveDiffer`, respectively.
107+
Type of ArchiveDiffer to run. Must be one of ["git", "s3"] which correspond to
108+
`GitArchiveDiffer` and `S3ArchiveDiffer`, respectively.
108109
cache_dir: str
109110
The directory for storing most recent archived/uploaded CSVs to start diffing from.
110111
export_dir: str
@@ -351,7 +352,7 @@ def update_cache(self):
351352

352353
self._cache_updated = True
353354

354-
def archive_exports(self,
355+
def archive_exports(self, # pylint: disable=arguments-differ
355356
exported_files: Files,
356357
update_cache: bool = True,
357358
update_s3: bool = True

_delphi_utils_python/delphi_utils/export.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Export data in the format expected by the Delphi API."""
12
# -*- coding: utf-8 -*-
23
from datetime import datetime
34
from os.path import join

_delphi_utils_python/delphi_utils/geomap.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
- remove deprecated functions once integration into JHU and Quidel is refactored
1010
see: https://github.com/cmu-delphi/covidcast-indicators/issues/283
1111
"""
12-
12+
# pylint: disable=too-many-lines
1313
from os.path import join
1414
import warnings
1515
import pkg_resources
@@ -41,7 +41,7 @@
4141
}
4242

4343

44-
class GeoMapper:
44+
class GeoMapper: # pylint: disable=too-many-public-methods
4545
"""Geo mapping tools commonly used in Delphi.
4646
4747
The GeoMapper class provides utility functions for translating between different
@@ -301,7 +301,7 @@ def add_geocode(
301301
df[from_col] = df[from_col].astype(str)
302302

303303
# Assuming that the passed-in records are all United States data, at the moment
304-
if (from_code, new_code) in [("fips", "nation"), ("zip", "nation")]:
304+
if (from_code, new_code) in [("fips", "nation"), ("zip", "nation")]: # pylint: disable=no-else-return
305305
df[new_col] = df[from_col].apply(lambda x: "us")
306306
return df
307307
elif new_code == "nation":
@@ -724,7 +724,7 @@ def convert_state_code_to_state_id(
724724
)
725725

726726
state_table = self._load_crosswalk(from_code="state", to_code="state")
727-
state_table = state_table[["state_code", "state_id"]].rename(
727+
state_table = state_table[["state_code", "state_id"]].rename( # pylint: disable=unsubscriptable-object
728728
columns={"state_id": state_id_col}
729729
)
730730
data = data.copy()
@@ -796,7 +796,7 @@ def convert_zip_to_hrr(self, data, zip_col="zip", hrr_col="hrr"):
796796
return data
797797

798798
def convert_zip_to_msa(
799-
self, data, zip_col="zip", msa_col="msa", date_col="date", count_cols=None
799+
self, data, zip_col="zip", date_col="date", count_cols=None
800800
):
801801
"""DEPRECATED."""
802802
warnings.warn(
@@ -828,7 +828,6 @@ def zip_to_msa(
828828
data = self.convert_zip_to_msa(
829829
data,
830830
zip_col=zip_col,
831-
msa_col=msa_col,
832831
date_col=date_col,
833832
count_cols=count_cols,
834833
)

_delphi_utils_python/delphi_utils/smooth.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import pandas as pd
1717

1818

19-
class Smoother:
19+
class Smoother: # pylint: disable=too-many-instance-attributes
2020
"""
2121
This is the smoothing utility class. This class holds the parameter settings for its smoother
2222
methods and provides reasonable defaults. Basic usage can be found in the examples below.
@@ -66,8 +66,8 @@ class Smoother:
6666
Methods
6767
----------
6868
smooth: np.ndarray or pd.Series
69-
Takes a 1D signal and returns a smoothed version. The input and the output have the same length
70-
and type.
69+
Takes a 1D signal and returns a smoothed version.
70+
The input and the output have the same lengthand type.
7171
7272
Example Usage
7373
-------------
@@ -244,20 +244,21 @@ def left_gauss_linear_smoother(self, signal):
244244
)
245245
n = len(signal)
246246
signal_smoothed = np.zeros_like(signal)
247-
A = np.vstack([np.ones(n), np.arange(n)]).T # the regression design matrix
247+
# A is the regression design matrix
248+
A = np.vstack([np.ones(n), np.arange(n)]).T # pylint: disable=invalid-name
248249
for idx in range(n):
249250
weights = np.exp(
250251
-((np.arange(idx + 1) - idx) ** 2) / self.gaussian_bandwidth
251252
)
252-
AwA = np.dot(A[: (idx + 1), :].T * weights, A[: (idx + 1), :])
253-
Awy = np.dot(
253+
AwA = np.dot(A[: (idx + 1), :].T * weights, A[: (idx + 1), :]) # pylint: disable=invalid-name
254+
Awy = np.dot( # pylint: disable=invalid-name
254255
A[: (idx + 1), :].T * weights, signal[: (idx + 1)].reshape(-1, 1)
255256
)
256257
try:
257258
beta = np.linalg.solve(AwA, Awy)
258259
signal_smoothed[idx] = np.dot(A[: (idx + 1), :], beta)[-1]
259260
except np.linalg.LinAlgError:
260-
signal_smoothed[idx] = signal[idx] if self.impute else np.nan
261+
signal_smoothed[idx] = signal[idx] if self.impute else np.nan # pylint: disable=using-constant-test
261262
if self.minval is not None:
262263
signal_smoothed[signal_smoothed <= self.minval] = self.minval
263264
return signal_smoothed
@@ -318,7 +319,7 @@ def savgol_coeffs(self, nl, nr):
318319
if nr > 0:
319320
raise warnings.warn("The filter is no longer causal.")
320321

321-
A = np.vstack(
322+
A = np.vstack( # pylint: disable=invalid-name
322323
[np.arange(nl, nr + 1) ** j for j in range(self.poly_fit_degree + 1)]
323324
).T
324325

@@ -367,7 +368,7 @@ def savgol_smoother(self, signal):
367368
# - shortened_window (default) applies savgol with a smaller window to do the fit
368369
# - identity keeps the original signal (doesn't smooth)
369370
# - nan writes nans
370-
if self.boundary_method == "shortened_window":
371+
if self.boundary_method == "shortened_window": # pylint: disable=no-else-return
371372
for ix in range(len(self.coeffs)):
372373
if ix == 0:
373374
signal_smoothed[ix] = signal[ix]

_delphi_utils_python/delphi_utils/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Read parameter files containing configuration information."""
12
# -*- coding: utf-8 -*-
23
from json import load
34
from os.path import exists

0 commit comments

Comments
 (0)