Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
tev
plugin_event
Commits
55d326ae
Commit
55d326ae
authored
Mar 16, 2017
by
LE GAC Renaud
Browse files
Update report_tools to add protections.
parent
a294c3d6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
17 deletions
+36
-17
modules/plugin_event/report_tools.py
modules/plugin_event/report_tools.py
+36
-17
No files found.
modules/plugin_event/report_tools.py
View file @
55d326ae
...
...
@@ -196,23 +196,22 @@ class Graph(object):
"""
def
__init__
(
self
,
metric2d
,
backend
=
"Agg"
):
#
report
configuration
# configuration
config
=
metric2d
.
config
selector
=
metric2d
.
selector
selector
.
graph
=
json
.
loads
(
selector
.
graph
)
config_graph
=
(
selector
.
graph
if
selector
.
is_graph
else
config
.
graph
)
kind
=
config_graph
[
u
"kind"
]
# protection
if
selector
.
is_graph
and
kind
in
(
None
,
""
):
raise
ReportException
(
MSG_NO_KIND
)
if
len
(
kind
)
==
0
:
if
config_graph
is
None
or
config_graph
[
u
"kind"
]
in
(
None
,
""
)
:
self
.
ax
=
None
return
kind
=
config_graph
[
u
"kind"
]
if
selector
.
is_graph
and
kind
in
(
None
,
""
):
raise
ReportException
(
MSG_NO_KIND
)
# alias
group_field_x
=
config
.
group_field_x
group_field_y
=
config
.
group_field_y
...
...
@@ -272,10 +271,16 @@ class Graph(object):
matplotlib.axes or None
"""
ax
=
(
df
.
set_index
(
group_field_y
)
.
transpose
()
.
plot
(
**
config_graph
))
if
group_field_y
in
df
.
columns
:
ax
=
(
df
.
set_index
(
group_field_y
)
.
transpose
()
.
plot
(
**
config_graph
))
else
:
ax
=
(
df
.
transpose
()
.
plot
(
**
config_graph
))
# tick and axis labels
xlabel
,
ylabel
=
group_field_x
,
metric_field_z
...
...
@@ -323,8 +328,10 @@ class Graph(object):
# graph
df1
=
df
.
transpose
()
df1
.
columns
=
df1
.
loc
[
group_field_y
,
:]
df1
=
df1
[
df1
.
index
!=
group_field_y
]
if
group_field_y
in
df
.
columns
:
df1
.
columns
=
df1
.
loc
[
group_field_y
,
:]
df1
=
df1
[
df1
.
index
!=
group_field_y
]
ax
=
df1
.
plot
(
**
config_graph
)
...
...
@@ -375,9 +382,12 @@ class Graph(object):
# prepare the DataFrame
df1
=
df
.
transpose
()
df1
.
columns
=
df1
.
loc
[
group_field_y
,
:]
df1
=
(
df1
[
df1
.
index
!=
group_field_y
]
.
reset_index
())
if
group_field_y
in
df
.
columns
:
df1
.
columns
=
df1
.
loc
[
group_field_y
,
:]
df1
=
df1
[
df1
.
index
!=
group_field_y
]
df1
=
df1
.
reset_index
()
# graph
# colorize the point, one color per columns
...
...
@@ -421,6 +431,9 @@ class Graph(object):
fmt (str): possible values are pdf, png and svg.
"""
if
self
.
ax
is
None
:
return
""
fig
=
self
.
ax
.
get_figure
()
fi
=
StringIO
()
...
...
@@ -716,7 +729,13 @@ class Metric2D(BaseReport):
# preserve the original DataFrame in order to avoid pollution
# when series of summaries is computed
self
.
df0
=
df
if
len
(
summary_x
[
"functions"
])
>
0
or
len
(
summary_y
[
"functions"
])
>
0
:
# add summary rows and or columns
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment