peak-performance 0.6.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,122 @@
1
+ import os
2
+ from pathlib import Path
3
+
4
+ import arviz as az
5
+ import numpy as np
6
+ import pandas
7
+
8
+ from peak_performance import plots
9
+
10
+
11
+ def test_plot_raw_data():
12
+ """
13
+ Tests the plot_raw_data() function from the plots module.
14
+ """
15
+ identifier = "test_plot_raw_data"
16
+ path = Path(__file__).absolute().parent.parent / "test_data"
17
+ plots.plot_raw_data(
18
+ identifier=identifier,
19
+ time=np.array([1, 2, 3, 4, 5]),
20
+ intensity=np.array([1, 10, 25, 10, 1]),
21
+ path=path,
22
+ )
23
+ assert Path(path / f"{identifier}_NoPeak.png").exists()
24
+ assert Path(path / f"{identifier}_NoPeak.svg").exists()
25
+ os.remove(path / f"{identifier}_NoPeak.png")
26
+ os.remove(path / f"{identifier}_NoPeak.svg")
27
+ pass
28
+
29
+
30
+ def test_plot_posterior_predictive():
31
+ """
32
+ Tests the plot_posterior_predictive() function from the plots module.
33
+ """
34
+ path = Path(__file__).absolute().parent.parent / "test_data/test_plot_posterior_predictive"
35
+ idata = az.from_netcdf(path / "idata.nc")
36
+ time = idata.constant_data.time.values
37
+ intensity = idata.constant_data.intensity.values
38
+ identifier = "identifier"
39
+ # test plots of discarded signals
40
+ plots.plot_posterior_predictive(
41
+ identifier=identifier,
42
+ time=time,
43
+ intensity=intensity,
44
+ path=path,
45
+ idata=idata,
46
+ discarded=True,
47
+ )
48
+ assert (path / f"{identifier}_predictive_posterior_NoPeak.png").exists()
49
+ assert (path / f"{identifier}_predictive_posterior_NoPeak.svg").exists()
50
+ os.remove(path / f"{identifier}_predictive_posterior_NoPeak.png")
51
+ os.remove(path / f"{identifier}_predictive_posterior_NoPeak.svg")
52
+ # test plots of accepted signals
53
+ plots.plot_posterior_predictive(
54
+ identifier=identifier,
55
+ time=time,
56
+ intensity=intensity,
57
+ path=path,
58
+ idata=idata,
59
+ discarded=False,
60
+ )
61
+ assert Path(path / f"{identifier}_predictive_posterior.png").exists()
62
+ assert Path(path / f"{identifier}_predictive_posterior.svg").exists()
63
+ os.remove(path / f"{identifier}_predictive_posterior.png")
64
+ os.remove(path / f"{identifier}_predictive_posterior.svg")
65
+ pass
66
+
67
+
68
+ def test_plot_posterior():
69
+ """
70
+ Tests the plot_posterior() function from the plots module.
71
+ """
72
+ path = Path(__file__).absolute().parent.parent / "test_data/test_plot_posterior"
73
+ idata = az.from_netcdf(path / "idata.nc")
74
+ time = idata.constant_data.time.values
75
+ intensity = idata.constant_data.intensity.values
76
+ identifier = "identifier"
77
+ # test plots of discarded signals
78
+ plots.plot_posterior(
79
+ identifier=identifier,
80
+ time=time,
81
+ intensity=intensity,
82
+ path=path,
83
+ idata=idata,
84
+ discarded=True,
85
+ )
86
+ assert (path / f"{identifier}_posterior_NoPeak.png").exists()
87
+ assert (path / f"{identifier}_posterior_NoPeak.svg").exists()
88
+ os.remove(path / f"{identifier}_posterior_NoPeak.png")
89
+ os.remove(path / f"{identifier}_posterior_NoPeak.svg")
90
+ # test plots of accepted signals
91
+ plots.plot_posterior(
92
+ identifier=identifier,
93
+ time=time,
94
+ intensity=intensity,
95
+ path=path,
96
+ idata=idata,
97
+ discarded=False,
98
+ )
99
+ assert (path / f"{identifier}_posterior.png").exists()
100
+ assert (path / f"{identifier}_posterior.svg").exists()
101
+ os.remove(path / f"{identifier}_posterior.png")
102
+ os.remove(path / f"{identifier}_posterior.svg")
103
+ pass
104
+
105
+
106
+ def test_plot_model_comparison():
107
+ """
108
+ Tests the plot_model_comparison() function from the plots module.
109
+ """
110
+ path = Path(__file__).absolute().parent.parent / "test_data/test_plot_model_comparison"
111
+ ranking = pandas.read_excel(path / "ranking.xlsx")
112
+ identifier = "ranking"
113
+ plots.plot_model_comparison(
114
+ df_comp=ranking,
115
+ identifier="ranking",
116
+ path=path,
117
+ )
118
+ assert Path(path / f"model_comparison_{identifier}.png").exists()
119
+ assert Path(path / f"model_comparison_{identifier}.svg").exists()
120
+ os.remove(path / f"model_comparison_{identifier}.png")
121
+ os.remove(path / f"model_comparison_{identifier}.svg")
122
+ pass