1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
import holoviews as hv
import matplotlib as mpl
import numpy as np
import pytest
from pyecsca.sca.trace import Trace
from pyecsca.sca.trace.plot import (
plot_trace,
save_figure,
save_figure_png,
save_figure_svg,
plot_traces,
)
@pytest.fixture()
def trace1():
return Trace(np.array([6, 7, 3, -2, 5, 1], dtype=np.dtype("i1")))
@pytest.fixture()
def trace2():
return Trace(np.array([2, 3, 7, 0, -1, 0], dtype=np.dtype("i1")))
def test_html(trace1, trace2, plot_path):
hv.extension("bokeh")
fig = plot_trace(trace1)
save_figure(fig, str(plot_path()))
other = plot_traces(trace1, trace2)
save_figure(other, str(plot_path()))
@pytest.mark.skip("Broken")
def test_png(trace1, plot_path):
hv.extension("matplotlib")
mpl.use("agg")
fig = plot_trace(trace1)
save_figure_png(fig, str(plot_path()))
@pytest.mark.skip("Broken without some backend.")
def test_svg(trace1, plot_path):
hv.extension("matplotlib")
fig = plot_trace(trace1)
save_figure_svg(fig, str(plot_path()))
|