Skip to content

Commit

Permalink
Replaced mutable default args with None
Browse files Browse the repository at this point in the history
  • Loading branch information
kaklise committed Mar 5, 2021
1 parent 394ebab commit 2554c3e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 15 deletions.
4 changes: 3 additions & 1 deletion documentation/whatsnew/v0.2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ v0.2.0 (master)

* Replaced the use of Excel files in examples/tests with CSV files. The Excel files were causing test failures.
* Added `min_failures` to the streaming outlier test
* Replaced mutable default arguments with None
* Removed pecos logo from monitoring reports
* Added timestamp to the logger
* Added timestamp to logger
* Updated documentation and tests

14 changes: 8 additions & 6 deletions pecos/graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,8 @@ def plot_interactive_timeseries(data, xaxis_min=None, xaxis_max=None, yaxis_min=
else:
plotly.offline.plot(fig, auto_open=auto_open)

def plot_heatmap(data, colors=[(0.75, 0.15, 0.15), (1, 0.75, 0.15), (0.15, 0.75, 0.15)],
nColors=12, cmap=None, vmin=None, vmax=None,
show_axis=False, title=None, figsize=(5.0, 5.0)):
def plot_heatmap(data, colors=None, nColors=12, cmap=None, vmin=None, vmax=None,
show_axis=False, title=None, figsize=(5.0, 5.0)):
"""
Create a heatmap. Default color scheme is red to yellow to green with 12
colors. This function can be used to generate dashboards with simple color
Expand All @@ -319,10 +318,10 @@ def plot_heatmap(data, colors=[(0.75, 0.15, 0.15), (1, 0.75, 0.15), (0.15, 0.75,
data : pandas DataFrame, pandas Series, or numpy array
Data
colors : list, optional
colors : list or None, optional
List of colors, colors can be specified in any way understandable by
matplotlib.colors.ColorConverter.to_rgb().
Default is red to yellow to green.
If None, colors transitions from red to yellow to green.
num_colors : int, optional
Number of colors in the colormap, default = 12
Expand All @@ -342,8 +341,11 @@ def plot_heatmap(data, colors=[(0.75, 0.15, 0.15), (1, 0.75, 0.15), (0.15, 0.75,
figsize : tuple, optional
Figure size, default = (5.0, 5.0)
"""
if colors is None:
colors = [(0.75, 0.15, 0.15), (1, 0.75, 0.15), (0.15, 0.75, 0.15)]

if isinstance(data, (pd.DataFrame, pd.Series)):
data = data.values
data = data.values
if len(data.shape) == 1:
data = np.expand_dims(data, axis=0)

Expand Down
26 changes: 18 additions & 8 deletions pecos/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ def write_test_results(test_results, filename='test_results.csv'):

return full_filename

def write_monitoring_report(data, test_results, test_results_graphics=[],
custom_graphics=[], metrics=None,
title='Pecos Monitoring Report', config={}, logo=False,
def write_monitoring_report(data, test_results, test_results_graphics=None,
custom_graphics=None, metrics=None,
title='Pecos Monitoring Report', config=None, logo=False,
im_width_test_results=1, im_width_custom=1, im_width_logo=0.1,
encode=False, file_format='html',
filename='monitoring_report.html'):
Expand All @@ -236,21 +236,24 @@ def write_monitoring_report(data, test_results, test_results_graphics=[],
test_results : pandas DataFrame
Summary of the quality control test results (pm.test_results)
test_results_graphics : list of strings, optional
test_results_graphics : list of strings or None, optional
Graphics files, with full path. These graphics highlight data points
that failed a quality control test, created using pecos.graphics.plot_test_results()
that failed a quality control test, created using pecos.graphics.plot_test_results().
If None, test results graphics are not included in the report.
custom_graphics : list of strings, optional
custom_graphics : list of strings or None, optional
Custom files, with full path. Created by the user.
If None, custom graphics are not included in the report.
metrics : pandas Series or DataFrame, optional
Performance metrics to add as a table to the monitoring report
title : string, optional
Monitoring report title, default = 'Pecos Monitoring Report'
config : dictionary, optional
Configuration options, to be printed at the end of the report
config : dictionary or None, optional
Configuration options, to be printed at the end of the report.
If None, configuration options are not included in the report.
logo : string, optional
Graphic to be added to the report header
Expand Down Expand Up @@ -278,6 +281,13 @@ def write_monitoring_report(data, test_results, test_results_graphics=[],
"""
logger.info("Writing HTML report")

if test_results_graphics is None:
test_results_graphics = []
if custom_graphics is None:
custom_graphics = []
if config is None:
config = {}

if data.empty:
logger.warning("Empty database")
start_time = 'NaN'
Expand Down

0 comments on commit 2554c3e

Please sign in to comment.