aboutsummaryrefslogtreecommitdiff
path: root/test/sca/test_plot.py
blob: 5b65c87144a0c24cc2bb2fd0e572e3571da38606 (plain)
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
from os import getenv

import numpy as np
import holoviews as hv
from pyecsca.sca.trace import Trace
from pyecsca.sca.trace.plot import (plot_trace, save_figure, save_figure_png, save_figure_svg,
                                    plot_traces)
from .utils import Plottable


class PlotTests(Plottable):

    def setUp(self) -> None:
        self.trace1 = Trace(np.array([6, 7, 3, -2, 5, 1], dtype=np.dtype("i1")))
        self.trace2 = Trace(np.array([2, 3, 7, 0, -1, 0], dtype=np.dtype("i1")))

    def test_html(self):
        if getenv("PYECSCA_TEST_PLOTS") is None:
            return
        hv.extension("bokeh")
        fig = plot_trace(self.trace1)
        save_figure(fig, self.get_fname())
        other = plot_traces(self.trace1, self.trace2)
        save_figure(other, self.get_fname())

    def test_png(self):
        if getenv("PYECSCA_TEST_PLOTS") is None:
            return
        hv.extension("matplotlib")
        fig = plot_trace(self.trace1)
        save_figure_png(fig, self.get_fname())

    def test_svg(self):
        if getenv("PYECSCA_TEST_PLOTS") is None:
            return
        hv.extension("matplotlib")
        fig = plot_trace(self.trace1)
        save_figure_svg(fig, self.get_fname())