@@ -174,7 +174,7 PYBIND11_MODULE(pysciqlopcore, m) | |||||
174 | ScalarTimeSerie::axis_t _values(t.size()); |
|
174 | ScalarTimeSerie::axis_t _values(t.size()); | |
175 | auto t_vew = t.unchecked<1>(); |
|
175 | auto t_vew = t.unchecked<1>(); | |
176 | auto values_vew = values.unchecked<1>(); |
|
176 | auto values_vew = values.unchecked<1>(); | |
177 |
for( |
|
177 | for(std::size_t i = 0; i < t.size(); i++) | |
178 | { |
|
178 | { | |
179 | _t[i] = t_vew[i]; |
|
179 | _t[i] = t_vew[i]; | |
180 | _values[i] = values_vew[i]; |
|
180 | _values[i] = values_vew[i]; | |
@@ -197,6 +197,21 PYBIND11_MODULE(pysciqlopcore, m) | |||||
197 | py::class_<VectorTimeSerie, TimeSeries::ITimeSerie>(m, "VectorTimeSerie") |
|
197 | py::class_<VectorTimeSerie, TimeSeries::ITimeSerie>(m, "VectorTimeSerie") | |
198 | .def(py::init<>()) |
|
198 | .def(py::init<>()) | |
199 | .def(py::init<std::size_t>()) |
|
199 | .def(py::init<std::size_t>()) | |
|
200 | .def(py::init([](py::array_t<double> t, py::array_t<double> values) { | |||
|
201 | assert(t.size() * 3 == values.size()); | |||
|
202 | VectorTimeSerie::axis_t _t(t.size()); | |||
|
203 | VectorTimeSerie::container_type<VectorTimeSerie::raw_value_type> | |||
|
204 | _values(t.size()); | |||
|
205 | auto t_vew = t.unchecked<1>(); | |||
|
206 | auto values_vew = values.unchecked<2>(); | |||
|
207 | for(std::size_t i = 0; i < t.size(); i++) | |||
|
208 | { | |||
|
209 | _t[i] = t_vew[i]; | |||
|
210 | _values[i] = VectorTimeSerie::raw_value_type{ | |||
|
211 | values_vew(0, i), values_vew(1, i), values_vew(2, i)}; | |||
|
212 | } | |||
|
213 | return VectorTimeSerie(_t, _values); | |||
|
214 | })) | |||
200 | .def("__getitem__", |
|
215 | .def("__getitem__", | |
201 | [](VectorTimeSerie& ts, std::size_t key) |
|
216 | [](VectorTimeSerie& ts, std::size_t key) | |
202 | -> VectorTimeSerie::raw_value_type& { return ts[key]; }, |
|
217 | -> VectorTimeSerie::raw_value_type& { return ts[key]; }, |
@@ -37,5 +37,8 class TimeSeriesData(unittest.TestCase): | |||||
37 | def test_build_ScalarTimeSerie_from_np_arrays(self): |
|
37 | def test_build_ScalarTimeSerie_from_np_arrays(self): | |
38 | ts = pysciqlopcore.ScalarTimeSerie(np.arange(10),np.zeros(10)) |
|
38 | ts = pysciqlopcore.ScalarTimeSerie(np.arange(10),np.zeros(10)) | |
39 |
|
39 | |||
|
40 | def test_build_VectorTimeSerie_from_np_arrays(self): | |||
|
41 | ts = pysciqlopcore.VectorTimeSerie(np.arange(10),np.zeros((3,10))) | |||
|
42 | ||||
40 | if __name__ == '__main__': |
|
43 | if __name__ == '__main__': | |
41 | unittest.main() |
|
44 | unittest.main() |
General Comments 0
You need to be logged in to leave comments.
Login now