Skip to content

Commit

Permalink
Fix black linting
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephane Collot committed Sep 29, 2020
1 parent 2df943d commit 74c95f7
Show file tree
Hide file tree
Showing 32 changed files with 89 additions and 130 deletions.
8 changes: 3 additions & 5 deletions popmon/alerting/compute_tl_bounds.py
Expand Up @@ -67,7 +67,7 @@ def traffic_light_summary(row, cols=None, prefix=""):


def traffic_light(value, red_high, yellow_high, yellow_low=0, red_low=0):
""" Get corresponding traffic light given a value and traffic light bounds.
"""Get corresponding traffic light given a value and traffic light bounds.
:param float value: value to check
:param float red_high: higher bound of red traffic light
Expand Down Expand Up @@ -337,8 +337,7 @@ def df_single_op_pull_bounds(


class DynamicBounds(Pipeline):
""" Calculate dynamic traffic light bounds based on pull thresholds and dynamic mean and std.deviation.
"""
"""Calculate dynamic traffic light bounds based on pull thresholds and dynamic mean and std.deviation."""

def __init__(
self, read_key, rules, store_key="", suffix_mean="_mean", suffix_std="_std"
Expand Down Expand Up @@ -380,8 +379,7 @@ def transform(self, datastore):


class StaticBounds(Pipeline):
""" Calculate static traffic light bounds based on pull thresholds and static mean and std.deviation.
"""
"""Calculate static traffic light bounds based on pull thresholds and static mean and std.deviation."""

def __init__(
self, read_key, rules, store_key="", suffix_mean="_mean", suffix_std="_std"
Expand Down
4 changes: 2 additions & 2 deletions popmon/analysis/apply_func.py
Expand Up @@ -187,7 +187,7 @@ def transform(self, datastore):
def apply_func_array(
feature, metrics, apply_to_df, assign_to_df, apply_funcs, same_key
):
""" Apply list of functions to dataframe
"""Apply list of functions to dataframe
Split off for parallellization reasons
Expand Down Expand Up @@ -231,7 +231,7 @@ def apply_func_array(


def apply_func(feature, selected_metrics, df, arr):
""" Apply function to dataframe
"""Apply function to dataframe
:param str feature: feature currently looping over
:param list selected_metrics: list of selected metrics to apply to
Expand Down
27 changes: 9 additions & 18 deletions popmon/analysis/comparison/hist_comparer.py
Expand Up @@ -135,8 +135,7 @@ def hist_compare(row, hist_name1="", hist_name2="", max_res_bound=7.0):


class HistComparer(Pipeline):
""" Base pipeline to compare histogram to previous rolling histograms
"""
"""Base pipeline to compare histogram to previous rolling histograms"""

def __init__(
self,
Expand Down Expand Up @@ -192,8 +191,7 @@ def __init__(


class RollingHistComparer(HistComparer):
""" Compare histogram to previous rolling histograms
"""
"""Compare histogram to previous rolling histograms"""

def __init__(
self,
Expand Down Expand Up @@ -238,8 +236,7 @@ def transform(self, datastore):


class PreviousHistComparer(RollingHistComparer):
""" Compare histogram to previous histograms
"""
"""Compare histogram to previous histograms"""

def __init__(
self,
Expand All @@ -262,8 +259,7 @@ def __init__(


class ExpandingHistComparer(HistComparer):
""" Compare histogram to previous expanding histograms
"""
"""Compare histogram to previous expanding histograms"""

def __init__(
self,
Expand Down Expand Up @@ -305,8 +301,7 @@ def transform(self, datastore):


class ReferenceHistComparer(HistComparer):
""" Compare histogram to reference histograms
"""
"""Compare histogram to reference histograms"""

def __init__(
self,
Expand Down Expand Up @@ -349,8 +344,7 @@ def transform(self, datastore):


class NormHistComparer(Pipeline):
""" Base pipeline to compare histogram to normalized histograms
"""
"""Base pipeline to compare histogram to normalized histograms"""

def __init__(
self,
Expand Down Expand Up @@ -396,8 +390,7 @@ def __init__(


class RollingNormHistComparer(NormHistComparer):
""" Compare histogram to previous rolling normalized histograms
"""
"""Compare histogram to previous rolling normalized histograms"""

def __init__(self, read_key, store_key, window, shift=1, hist_col="histogram"):
"""Initialize an instance of RollingNormHistComparer.
Expand Down Expand Up @@ -425,8 +418,7 @@ def transform(self, datastore):


class ExpandingNormHistComparer(NormHistComparer):
""" Compare histogram to previous expanding normalized histograms
"""
"""Compare histogram to previous expanding normalized histograms"""

def __init__(self, read_key, store_key, shift=1, hist_col="histogram"):
"""Initialize an instance of ExpandingNormHistComparer.
Expand All @@ -450,8 +442,7 @@ def transform(self, datastore):


class ReferenceNormHistComparer(NormHistComparer):
""" Compare histogram to reference normalized histograms
"""
"""Compare histogram to reference normalized histograms"""

def __init__(self, reference_key, assign_to_key, store_key, hist_col="histogram"):
"""Initialize an instance of ReferenceNormHistComparer.
Expand Down
2 changes: 1 addition & 1 deletion popmon/analysis/functions.py
Expand Up @@ -382,7 +382,7 @@ def expand_norm_hist_mean_cov(df, shift=1, *args, **kwargs):


def normalized_hist_mean_cov(x, hist_name=""):
""" Mean normalized histogram and its covariance of list of input histograms
"""Mean normalized histogram and its covariance of list of input histograms
Usage: df['hists'].apply(normalized_hist_mean_cov) ; series.apply(normalized_hist_mean_cov)
Expand Down
12 changes: 6 additions & 6 deletions popmon/analysis/hist_numpy.py
Expand Up @@ -66,7 +66,7 @@ def prepare_2dgrid(hist):


def set_2dgrid(hist, xkeys, ykeys):
""" Set 2d grid of first two dimenstions of input histogram
"""Set 2d grid of first two dimenstions of input histogram
Used as input by get_2dgrid(hist).
Expand Down Expand Up @@ -116,7 +116,7 @@ def set_2dgrid(hist, xkeys, ykeys):


def get_2dgrid(hist, get_bin_labels=False):
""" Get filled x,y grid of first two dimensions of input histogram
"""Get filled x,y grid of first two dimensions of input histogram
:param hist: input histogrammar histogram
:return: x,y grid of first two dimenstions of input histogram
Expand All @@ -141,7 +141,7 @@ def get_2dgrid(hist, get_bin_labels=False):


def get_consistent_numpy_2dgrids(hc_list=[], get_bin_labels=False):
""" Get list of consistent x,y grids of first two dimensions of (sparse) input histograms
"""Get list of consistent x,y grids of first two dimensions of (sparse) input histograms
:param list hc_list: list of input histogrammar histograms
:param bool get_bin_labels: if true, return x-keys and y-keys describing binnings of 2d-grid.
Expand Down Expand Up @@ -181,7 +181,7 @@ def get_consistent_numpy_2dgrids(hc_list=[], get_bin_labels=False):


def get_consistent_numpy_1dhists(hc_list, get_bin_labels=False):
""" Get list of consistent numpy hists for list of sparse input histograms
"""Get list of consistent numpy hists for list of sparse input histograms
Note: a numpy histogram is a union of lists of bin_edges and number of entries
Expand Down Expand Up @@ -232,7 +232,7 @@ def get_consistent_numpy_1dhists(hc_list, get_bin_labels=False):


def get_consistent_numpy_entries(hc_list, get_bin_labels=False):
""" Get list of consistent numpy bin_entries for list of 1d input histograms
"""Get list of consistent numpy bin_entries for list of 1d input histograms
:param list hist_list: list of input histogrammar histograms
:return: list of consistent 1d numpy arrays with bin_entries for list of input histograms
Expand Down Expand Up @@ -439,7 +439,7 @@ def assert_similar_hists(hc_list, check_type=True, assert_type=used_hist_types):


def check_same_hists(hc1, hc2):
""" Check if two hists are the same
"""Check if two hists are the same
:param hc1: input histogram container 1
:param hc2: input histogram container 2
Expand Down
3 changes: 1 addition & 2 deletions popmon/analysis/merge_statistics.py
Expand Up @@ -24,8 +24,7 @@


class MergeStatistics(Module):
""" Merging dictionaries of features containing dataframes with statistics as its values.
"""
"""Merging dictionaries of features containing dataframes with statistics as its values."""

def __init__(self, read_keys, store_key):
"""Initialize an instance of MergeStatistics.
Expand Down
14 changes: 5 additions & 9 deletions popmon/analysis/profiling/pull_calculator.py
Expand Up @@ -34,7 +34,7 @@


class PullCalculator(Pipeline):
""" Base module for pull calculation, based on mean and standard deviation calculation
"""Base module for pull calculation, based on mean and standard deviation calculation
Steps as performed by ApplyFunc modules:
Expand Down Expand Up @@ -103,8 +103,7 @@ def __init__(


class RollingPullCalculator(PullCalculator):
""" Pull calculation based on rolling mean and standard deviations
"""
"""Pull calculation based on rolling mean and standard deviations"""

def __init__(
self,
Expand Down Expand Up @@ -158,8 +157,7 @@ def transform(self, datastore):


class ExpandingPullCalculator(PullCalculator):
""" Pull calculation based on expanding mean and standard deviations
"""
"""Pull calculation based on expanding mean and standard deviations"""

def __init__(
self,
Expand Down Expand Up @@ -210,8 +208,7 @@ def transform(self, datastore):


class ReferencePullCalculator(PullCalculator):
""" Pull calculation based on reference mean and standard deviations
"""
"""Pull calculation based on reference mean and standard deviations"""

def __init__(
self,
Expand Down Expand Up @@ -261,8 +258,7 @@ def transform(self, datastore):


class RefMedianMadPullCalculator(PullCalculator):
""" Pull calculation based on reference median and mad
"""
"""Pull calculation based on reference median and mad"""

def __init__(
self,
Expand Down
8 changes: 3 additions & 5 deletions popmon/base/module.py
Expand Up @@ -22,19 +22,17 @@


class Module:
"""Base class used for modules in a pipeline.
"""
"""Base class used for modules in a pipeline."""

def __init__(self):
"""Module initialization
"""
"""Module initialization"""
self.logger = logging.getLogger()
self.features = []
self.feature_begins_with = []
self.ignore_features = []

def set_logger(self, logger):
""" Set logger of module
"""Set logger of module
:param logger: input logger
"""
Expand Down
3 changes: 1 addition & 2 deletions popmon/base/pipeline.py
Expand Up @@ -24,8 +24,7 @@


class Pipeline(Module):
"""Base class used for to run modules in a pipeline.
"""
"""Base class used for to run modules in a pipeline."""

def __init__(self, modules, logger=None):
"""Initialization of the pipeline
Expand Down
6 changes: 2 additions & 4 deletions popmon/hist/filling/histogram_filler_base.py
Expand Up @@ -486,11 +486,9 @@ def get_hist_bin(self, hist, features, quant, col, dt):
value=hist,
)
else:
raise RuntimeError(
"Do not know how to interpret bin specifications."
)
raise RuntimeError("Do not know how to interpret bin specifications.")
else:
# string and boolians are treated as categories
hist = hg.Categorize(quantity=quant, value=hist)

return hist
return hist
2 changes: 1 addition & 1 deletion popmon/hist/filling/make_histograms.py
Expand Up @@ -47,7 +47,7 @@ def make_histograms(
nbins_3d=10,
max_nunique=500,
):
""" Create histograms from pandas or spark dataframe.
"""Create histograms from pandas or spark dataframe.
:param df: input pandas or spark dataframe to create histograms of.
:param list features: columns to pick up from input data. (default is all features)
Expand Down
2 changes: 1 addition & 1 deletion popmon/hist/filling/pandas_histogrammar.py
Expand Up @@ -107,7 +107,7 @@ def assert_dataframe(self, df):
return df

def get_features(self, df):
""" Get columns of (pandas) dataframe
"""Get columns of (pandas) dataframe
:param df: input pandas dataframe
"""
Expand Down
2 changes: 1 addition & 1 deletion popmon/hist/filling/spark_histogrammar.py
Expand Up @@ -112,7 +112,7 @@ def assert_dataframe(self, df):
return df

def get_features(self, df):
""" Get columns of dataframe
"""Get columns of dataframe
:param df: input spark dataframe
"""
Expand Down
17 changes: 7 additions & 10 deletions popmon/hist/histogram.py
Expand Up @@ -59,7 +59,7 @@ def sum_entries(hist_data, default=True):


def project_on_x(hist_data):
""" Project n-dim histogram onto x-axis
"""Project n-dim histogram onto x-axis
:param hist_data: input histogrammar histogram
:return: on x-axis projected histogram (1d)
Expand Down Expand Up @@ -108,7 +108,7 @@ def project_on_x(hist_data):


def sum_over_x(hist_data):
""" Integrate histogram over first dimension
"""Integrate histogram over first dimension
:param hist_data: input histogrammar histogram
:return: integrated histogram
Expand Down Expand Up @@ -147,7 +147,7 @@ def sum_over_x(hist_data):


def project_split2dhist_on_axis(splitdict, axis="x"):
""" Project a split 2d-histogram onto one axis
"""Project a split 2d-histogram onto one axis
Project a 2d hist that's been split with function split_hist_along_first_dimension
onto x or y axis.
Expand Down Expand Up @@ -175,8 +175,7 @@ def project_split2dhist_on_axis(splitdict, axis="x"):


class HistogramContainer:
"""Wrapper class around histogrammar histograms with several utility functions.
"""
"""Wrapper class around histogrammar histograms with several utility functions."""

def __init__(self, hist_obj):
"""Initialization
Expand Down Expand Up @@ -224,8 +223,7 @@ def _edit_name(self, axis_name, xname, yname, convert_time_index, short_keys):
return axis_name

def sparse_bin_centers_x(self):
""" Get x-axis bin centers of sparse histogram
"""
"""Get x-axis bin centers of sparse histogram"""
keys = sorted(self.hist.bins.keys())
if self.hist.minBin is None or self.hist.maxBin is None:
# number of bins is set to 1.
Expand All @@ -239,8 +237,7 @@ def sparse_bin_centers_x(self):
return centers, values

def get_bin_centers(self):
""" Get bin centers or labels of histogram
"""
"""Get bin centers or labels of histogram"""
if isinstance(self.hist, histogrammar.Bin): # Bin
centers, values = self.hist.bin_centers(), self.hist.values
elif isinstance(self.hist, histogrammar.SparselyBin):
Expand Down Expand Up @@ -295,7 +292,7 @@ def split_hist_along_first_dimension(
return hdict

def _filter_empty_split_hists(self, centers, values):
""" Filter empty split histograms from input centers and values
"""Filter empty split histograms from input centers and values
:param list centers: input center values list
:param list values: input values list
Expand Down

0 comments on commit 74c95f7

Please sign in to comment.