Skip to content

Commit 6a2430f

Browse files
committed
fixed a bug with detector.mesh.cartesian.x/y/z which were failing
1 parent 65d4538 commit 6a2430f

1 file changed

Lines changed: 6 additions & 39 deletions

File tree

PyMieSim/cpp/coordinates/interface.cpp

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,8 @@ PYBIND11_MODULE(coordinates, module)
2222
)
2323
.def_property_readonly(
2424
"x",
25-
[ureg](const Cartesian& self) {
26-
const pybind11::ssize_t number_of_rows = self.shape[0];
27-
const pybind11::ssize_t number_of_columns = self.shape[1];
28-
29-
return pybind11::array_t<double>(
30-
{number_of_rows, number_of_columns},
31-
{
32-
static_cast<pybind11::ssize_t>(sizeof(double) * number_of_columns),
33-
static_cast<pybind11::ssize_t>(sizeof(double))
34-
},
35-
self.x.data(),
36-
pybind11::cast(self)
37-
) * ureg("meter");
25+
[ureg](const Cartesian& self) -> pybind11::object {
26+
return pybind11::cast(self.x) * ureg("meter");
3827
},
3928
R"pbdoc(
4029
Returns x coordinates of points on the Cartesian mesh as a NumPy array.
@@ -43,19 +32,8 @@ PYBIND11_MODULE(coordinates, module)
4332
)
4433
.def_property_readonly(
4534
"y",
46-
[ureg](const Cartesian& self) {
47-
const pybind11::ssize_t number_of_rows = self.shape[0];
48-
const pybind11::ssize_t number_of_columns = self.shape[1];
49-
50-
return pybind11::array_t<double>(
51-
{number_of_rows, number_of_columns},
52-
{
53-
static_cast<pybind11::ssize_t>(sizeof(double) * number_of_columns),
54-
static_cast<pybind11::ssize_t>(sizeof(double))
55-
},
56-
self.y.data(),
57-
pybind11::cast(self)
58-
) * ureg("meter");
35+
[ureg](const Cartesian& self) -> pybind11::object {
36+
return pybind11::cast(self.y) * ureg("meter");
5937
},
6038
R"pbdoc(
6139
Returns y coordinates of points on the Cartesian mesh as a NumPy array.
@@ -64,19 +42,8 @@ PYBIND11_MODULE(coordinates, module)
6442
)
6543
.def_property_readonly(
6644
"z",
67-
[ureg](const Cartesian& self) {
68-
const pybind11::ssize_t number_of_rows = self.shape[0];
69-
const pybind11::ssize_t number_of_columns = self.shape[1];
70-
71-
return pybind11::array_t<double>(
72-
{number_of_rows, number_of_columns},
73-
{
74-
static_cast<pybind11::ssize_t>(sizeof(double) * number_of_columns),
75-
static_cast<pybind11::ssize_t>(sizeof(double))
76-
},
77-
self.z.data(),
78-
pybind11::cast(self)
79-
) * ureg("meter");
45+
[ureg](const Cartesian& self) -> pybind11::object {
46+
return pybind11::cast(self.z) * ureg("meter");
8047
},
8148
R"pbdoc(
8249
Returns z coordinates of points on the Cartesian mesh as a NumPy array.

0 commit comments

Comments
 (0)