@@ -1,1 +1,1 | |||||
1 | Subproject commit 2146d47985f44d6914b224c3b99ebf9e16e87b3f |
|
1 | Subproject commit e08e903b65e9d884187e1809c75b22379783bfee |
@@ -10,7 +10,13 class SCIQLOP_CORE_EXPORT SpectrogramTimeSerie | |||||
10 | { |
|
10 | { | |
11 | public: |
|
11 | public: | |
12 | using item_t = |
|
12 | using item_t = | |
13 | decltype(TimeSeries::TimeSerie<double, SpectrogramTimeSerie, 2>()[0]); |
|
13 | decltype(std::declval< | |
|
14 | TimeSeries::TimeSerie<double, SpectrogramTimeSerie, 2>>()[0]); | |||
|
15 | ||||
|
16 | using iterator_t = decltype( | |||
|
17 | std::declval<TimeSeries::TimeSerie<double, SpectrogramTimeSerie, 2>>() | |||
|
18 | .begin()); | |||
|
19 | ||||
14 | SpectrogramTimeSerie() {} |
|
20 | SpectrogramTimeSerie() {} | |
15 | ~SpectrogramTimeSerie() = default; |
|
21 | ~SpectrogramTimeSerie() = default; | |
16 | using TimeSerie::TimeSerie; |
|
22 | using TimeSerie::TimeSerie; |
@@ -73,15 +73,12 void copy_spectro(py::array_t<double>& t, py::array_t<double>& values, | |||||
73 | auto t_view = t.unchecked<1>(); |
|
73 | auto t_view = t.unchecked<1>(); | |
74 | auto values_view = values.unchecked<2>(); |
|
74 | auto values_view = values.unchecked<2>(); | |
75 | const auto width = values.shape(0); |
|
75 | const auto width = values.shape(0); | |
76 | std::cout << "WIDTH" << width << std::endl; |
|
|||
77 | for(std::size_t i = 0; i < t.size(); i++) |
|
76 | for(std::size_t i = 0; i < t.size(); i++) | |
78 | { |
|
77 | { | |
79 | dest_t[i] = t_view[i]; |
|
78 | dest_t[i] = t_view[i]; | |
80 | for(int j = 0; j < width; j++) |
|
79 | for(int j = 0; j < width; j++) | |
81 | { |
|
80 | { | |
82 | dest_values[i * width + j] = values_view(j, i); |
|
81 | dest_values[i * width + j] = values_view(j, i); | |
83 | std::cout << "dest_values[" << i * width + j << "] = values_view(" << j |
|
|||
84 | << ", " << i << ") = " << values_view(j, i) << std::endl; |
|
|||
85 | } |
|
82 | } | |
86 | } |
|
83 | } | |
87 | } |
|
84 | } | |
@@ -278,9 +275,12 PYBIND11_MODULE(pysciqlopcore, m) | |||||
278 | *(ts.begin() + key) = value; |
|
275 | *(ts.begin() + key) = value; | |
279 | }); |
|
276 | }); | |
280 |
|
277 | |||
281 |
py::class_<SpectrogramTimeSerie::ite |
|
278 | py::class_<SpectrogramTimeSerie::iterator_t>(m, "SpectrogramTimeSerieItem") | |
282 |
.def("__getitem__", [](SpectrogramTimeSerie::ite |
|
279 | .def("__getitem__", [](SpectrogramTimeSerie::iterator_t& self, | |
283 |
std::size_t key) { return self[key]; }) |
|
280 | std::size_t key) { return (*self)[key]; }) | |
|
281 | .def("__setitem__", | |||
|
282 | [](SpectrogramTimeSerie::iterator_t& self, std::size_t key, | |||
|
283 | double value) { (*self)[key] = value; }); | |||
284 |
|
284 | |||
285 | py::class_<SpectrogramTimeSerie, TimeSeries::ITimeSerie>( |
|
285 | py::class_<SpectrogramTimeSerie, TimeSeries::ITimeSerie>( | |
286 | m, "SpectrogramTimeSerie") |
|
286 | m, "SpectrogramTimeSerie") | |
@@ -299,7 +299,10 PYBIND11_MODULE(pysciqlopcore, m) | |||||
299 | return SpectrogramTimeSerie(_t, _values, shape); |
|
299 | return SpectrogramTimeSerie(_t, _values, shape); | |
300 | })) |
|
300 | })) | |
301 | .def("__getitem__", |
|
301 | .def("__getitem__", | |
302 |
[](SpectrogramTimeSerie& ts, |
|
302 | [](SpectrogramTimeSerie& ts, | |
|
303 | std::size_t key) -> SpectrogramTimeSerie::iterator_t { | |||
|
304 | return ts.begin() + key; | |||
|
305 | }); | |||
303 |
|
306 | |||
304 | py::class_<Variable2, std::shared_ptr<Variable2>>(m, "Variable2") |
|
307 | py::class_<Variable2, std::shared_ptr<Variable2>>(m, "Variable2") | |
305 | .def(py::init<const QString&>()) |
|
308 | .def(py::init<const QString&>()) |
@@ -39,6 +39,24 class TimeSeriesData(unittest.TestCase): | |||||
39 | ts[0]=123. |
|
39 | ts[0]=123. | |
40 | self.assertEqual(ts[0],123.) |
|
40 | self.assertEqual(ts[0],123.) | |
41 |
|
41 | |||
|
42 | def test_set_VectorTimeSerie_values(self): | |||
|
43 | ts = pysciqlopcore.VectorTimeSerie(10) | |||
|
44 | ts.t[0]=111. | |||
|
45 | self.assertEqual(ts.t[0],111.) | |||
|
46 | ts[0].x=111. | |||
|
47 | ts[0].y=222. | |||
|
48 | ts[0].z=333. | |||
|
49 | self.assertEqual(ts[0].x,111.) | |||
|
50 | self.assertEqual(ts[0].y,222.) | |||
|
51 | self.assertEqual(ts[0].z,333.) | |||
|
52 | ||||
|
53 | def test_set_SpectrogramTimeSerie_values(self): | |||
|
54 | ts = pysciqlopcore.SpectrogramTimeSerie((10,100)) | |||
|
55 | ts.t[0]=111. | |||
|
56 | self.assertEqual(ts.t[0],111.) | |||
|
57 | ts[0][11]=123. | |||
|
58 | self.assertEqual(ts[0][11],123.) | |||
|
59 | ||||
42 | def test_build_ScalarTimeSerie_from_np_arrays(self): |
|
60 | def test_build_ScalarTimeSerie_from_np_arrays(self): | |
43 | ts = pysciqlopcore.ScalarTimeSerie(np.arange(10), np.arange(10)*10) |
|
61 | ts = pysciqlopcore.ScalarTimeSerie(np.arange(10), np.arange(10)*10) | |
44 | for i in range(len(ts)): |
|
62 | for i in range(len(ts)): | |
@@ -81,8 +99,20 class TimeSeriesData(unittest.TestCase): | |||||
81 | ts = pysciqlopcore.SpectrogramTimeSerie(np.arange(10), v) |
|
99 | ts = pysciqlopcore.SpectrogramTimeSerie(np.arange(10), v) | |
82 | for i in range(len(ts)): |
|
100 | for i in range(len(ts)): | |
83 | for j in range(4): |
|
101 | for j in range(4): | |
84 | print(f"ts[{i}][{j}] = " + str(ts[i][j])) |
|
102 | self.assertEqual(ts[i][j], i*10**j) | |
|
103 | ||||
|
104 | class VariableData(unittest.TestCase): | |||
|
105 | def test_default_state(self): | |||
|
106 | v=pysciqlopcore.Variable2("hello") | |||
|
107 | self.assertEqual(str(v.name), str("hello")) | |||
|
108 | self.assertEqual(type(v.data), type(None)) | |||
|
109 | self.assertEqual(len(v), 0) | |||
85 |
|
110 | |||
|
111 | def test_set_name(self): | |||
|
112 | v=pysciqlopcore.Variable2("hello") | |||
|
113 | self.assertEqual(str(v.name), str("hello")) | |||
|
114 | v.name="newName" | |||
|
115 | self.assertEqual(str(v.name), str("newName")) | |||
86 |
|
116 | |||
87 | if __name__ == '__main__': |
|
117 | if __name__ == '__main__': | |
88 | unittest.main(exit=False) |
|
118 | unittest.main(exit=False) |
General Comments 0
You need to be logged in to leave comments.
Login now