-
Notifications
You must be signed in to change notification settings - Fork 207
/
test_plot_model1d.py
69 lines (58 loc) · 2.38 KB
/
test_plot_model1d.py
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# -*- coding: utf-8 -*-
# Copyright 2007-2023 The HyperSpy developers
#
# This file is part of HyperSpy.
#
# HyperSpy is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# HyperSpy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with HyperSpy. If not, see <https://www.gnu.org/licenses/#GPL>.
import numpy as np
import pytest
from hyperspy.components1d import Expression
from hyperspy.signals import Signal1D
DEFAULT_TOL = 2.0
BASELINE_DIR = 'plot_model1d'
STYLE_PYTEST_MPL = 'default'
class TestModelPlot:
def setup_method(self, method):
s = Signal1D(np.arange(1000, dtype=np.int64).reshape((10, 100)))
s.add_poissonian_noise(random_state=0)
m = s.create_model()
line = Expression("a * x", name="line", a=1)
m.append(line)
self.m = m
@pytest.mark.mpl_image_compare(
baseline_dir=BASELINE_DIR, tolerance=DEFAULT_TOL, style=STYLE_PYTEST_MPL)
def test_default_signal_plot(self):
self.m.plot()
return self.m._plot.signal_plot.figure
@pytest.mark.mpl_image_compare(
baseline_dir=BASELINE_DIR, tolerance=DEFAULT_TOL, style=STYLE_PYTEST_MPL)
def test_plot_components(self):
self.m.plot(plot_components=True)
return self.m._plot.signal_plot.figure
@pytest.mark.mpl_image_compare(
baseline_dir=BASELINE_DIR, tolerance=DEFAULT_TOL, style=STYLE_PYTEST_MPL)
def test_disable_plot_components(self):
self.m.plot(plot_components=True)
self.m.disable_plot_components()
return self.m._plot.signal_plot.figure
@pytest.mark.mpl_image_compare(
baseline_dir=BASELINE_DIR, tolerance=DEFAULT_TOL, style=STYLE_PYTEST_MPL)
def test_default_navigator_plot(self):
self.m.plot()
return self.m._plot.navigator_plot.figure
def test_no_navigator(self):
self.m.plot(navigator=None)
assert self.m.signal._plot.navigator_plot is None
def test_plot_residual(self):
self.m.plot(plot_residual=True)