Commit 0498b874 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Updated report_tools to fix bugs in Metric2D and Graph.

parent 7e15a695
......@@ -198,7 +198,7 @@ class Graph(object):
config = metric2d.config
selector = metric2d.selector
selector.graph = selector.graph
selector.graph = json.loads(selector.graph)
config_graph = (selector.graph if selector.is_graph else config.graph)
......@@ -641,30 +641,33 @@ class Metric2D(BaseReport):
config = self.config
selector = self.selector
config_x = config.summary_x
config_y = config.summary_y
is_summary_x = selector.is_summary_x
is_summary_y = selector.is_summary_y
selector_x = selector.summary_x
selector_y = selector.summary_y
if selector.is_summary_x:
selector_x = selector.summary_x
summary_x = {
u"functions": selector_x[0],
u"labels": selector_x[1]}
else:
summary_x = config.summary_x
summary_x = (selector_x if is_summary_x else config_x)
summary_y = (selector_y if is_summary_y else config_y)
if selector.is_summary_y:
selector_y = selector.summary_y
summary_y = {
u"functions": selector_y[0],
u"labels": selector_y[1]}
else:
summary_y = config.summary_y
# preserve the original DataFrame in order to avoid pollution
# when series of summaries is computed
self.df0 = df
# add summary rows and or columns
is_summary = \
self.is_summary = is_summary = \
(summary_x is not None and len(summary_x["functions"]) > 0) or \
(summary_y is not None and len(summary_y["functions"]) > 0)
if is_summary:
self.df0 = df0 = df.copy()
self.is_summary = True
dfx = self.summaries(df0, summary_x, axis="columns")
df = pd.concat((df, dfx), axis="columns")
......@@ -688,9 +691,11 @@ class Metric2D(BaseReport):
df (pandas.DataFrame):
config (dict): configuration parameters for summaries:
* compute (bool)
* function(s) (str): string or list JSON-encoded
* label(s) (str): string or list JSON-encoded
* functions (str):
- string of values separated by comma
- list JSON-encoded
* labels (str): string of values separated by comma
axis (str): either ``rows`` of ``columns``.
......@@ -708,8 +713,8 @@ class Metric2D(BaseReport):
if funcs in ("", '""', "''", '[]'):
return df1
if not isinstance(funcs, list):
return df1
if isinstance(funcs, (str, unicode)):
funcs = funcs.split(",")
labels = config[u"labels"]
if labels in ("", '""', "''", "[]"):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment