Skip to content

Commit b739c5c

Browse files
committed
updated to ctor syntax
1 parent fcbaf0f commit b739c5c

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"ostream": "cpp",
2828
"system_error": "cpp",
2929
"type_traits": "cpp",
30-
"variant": "cpp"
30+
"variant": "cpp",
31+
"utility": "cpp"
3132
}
3233
}

src/main.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ py::array_t<double> get_ndarray(int n, double value)
4444

4545
struct VectorResults
4646
{
47+
VectorResults(const std::vector<double>& temperature,
48+
const std::vector<double>& humidity)
49+
: temperature(py::array(temperature.size(), temperature.data())),
50+
humidity(py::array(humidity.size(), humidity.data())){};
51+
4752
const py::array_t<double> temperature;
4853
const py::array_t<double> humidity;
4954
};
@@ -52,12 +57,7 @@ VectorResults get_vector_results(int len, double temp_value, double hum_value)
5257
{
5358
auto tmp = std::vector<double>(len, temp_value);
5459
auto hum = std::vector<double>(len, hum_value);
55-
VectorResults results = {
56-
py::array(tmp.size(), tmp.data()), // temperature
57-
py::array(hum.size(), hum.data()), // humidity
58-
};
59-
60-
return results;
60+
return VectorResults(tmp, hum);
6161
}
6262

6363
PYBIND11_MODULE(python_example, m)

0 commit comments

Comments
 (0)