Skip to content

Commit babddfb

Browse files
authored
Python: grid_spacing & time_offset double (#1290)
In `pybind11`, overloads on types are order-dependent (first wins). pybind/pybind11#1512 We specialize `double` here generically and cast in read if needed (see #345 #1137). Later on, we could add support for 1D numpy arrays with distinct type.
1 parent 19f5f88 commit babddfb

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

src/binding/python/Mesh.cpp

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,35 +71,25 @@ void init_Mesh(py::module &m)
7171
[](Mesh &mesh, char d) { mesh.setDataOrder(Mesh::DataOrder(d)); },
7272
"Data Order of the Mesh (deprecated and set to C in openPMD 2)")
7373
.def_property("axis_labels", &Mesh::axisLabels, &Mesh::setAxisLabels)
74-
.def_property(
75-
"grid_spacing",
76-
&Mesh::gridSpacing<float>,
77-
&Mesh::setGridSpacing<float>)
74+
75+
// note: overloads on types are order-dependent (first wins)
76+
// https://github.com/pybind/pybind11/issues/1512
77+
// We specialize `double` here generically and cast in read if needed.
78+
// Later on, we could add support for 1D numpy arrays with distinct
79+
// type.
7880
.def_property(
7981
"grid_spacing",
8082
&Mesh::gridSpacing<double>,
8183
&Mesh::setGridSpacing<double>)
82-
.def_property(
83-
"grid_spacing",
84-
&Mesh::gridSpacing<long double>,
85-
&Mesh::setGridSpacing<long double>)
8684
.def_property(
8785
"grid_global_offset",
8886
&Mesh::gridGlobalOffset,
8987
&Mesh::setGridGlobalOffset)
9088
.def_property("grid_unit_SI", &Mesh::gridUnitSI, &Mesh::setGridUnitSI)
91-
.def_property(
92-
"time_offset",
93-
&Mesh::timeOffset<float>,
94-
&Mesh::setTimeOffset<float>)
9589
.def_property(
9690
"time_offset",
9791
&Mesh::timeOffset<double>,
9892
&Mesh::setTimeOffset<double>)
99-
.def_property(
100-
"time_offset",
101-
&Mesh::timeOffset<long double>,
102-
&Mesh::setTimeOffset<long double>)
10393

10494
// TODO remove in future versions (deprecated)
10595
.def("set_unit_dimension", &Mesh::setUnitDimension)

0 commit comments

Comments
 (0)