Skip to content

Commit fd6602f

Browse files
Changed Binding Order
1 parent 6ae8935 commit fd6602f

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

bindings/src/Init.cc

+13-16
Original file line numberDiff line numberDiff line change
@@ -176,37 +176,34 @@ PYBIND11_PLUGIN(pydash) {
176176
m.def("barrier",
177177
(void (*)(void)) &(dash::barrier),
178178
"A global barrier involving all units.");
179-
179+
// ---------------------------------------------------------------------
180+
// pydash::logged_val
181+
//
182+
py::class_<pydash::logged_val> logged_val_py(m, "LV");
183+
logged_val_py
184+
.def(py::init<>())
185+
.def(py::init<int, const std::string &>())
186+
.def(py::init<const pydash::logged_val &>())
187+
.def("value", &pydash::logged_val::value)
188+
.def("set_value", &pydash::logged_val::set_value)
189+
.def("name", &pydash::logged_val::name);
190+
180191
// ---------------------------------------------------------------------
181192
// dash::GlobRef<T>
182193
//
183194
bind_type_glob_ref<int >(m, "Int");
184195
bind_type_glob_ref<float >(m, "Float");
185196
bind_type_glob_ref<double>(m, "Double");
197+
bind_type_glob_ref<pydash::logged_val>(m, "LV");
186198

187199
// ---------------------------------------------------------------------
188200
// dash::Array<T>
189201
//
190202
bind_type_array<int >(m, "Int");
191203
bind_type_array<float >(m, "Float");
192204
bind_type_array<double>(m, "Double");
193-
194-
// ---------------------------------------------------------------------
195-
// pydash::logged_val
196-
//
197-
py::class_<pydash::logged_val> logged_val_py(m, "LV");
198-
logged_val_py
199-
.def(py::init<>())
200-
.def(py::init<int, const std::string &>())
201-
.def(py::init<const pydash::logged_val &>())
202-
.def("value", &pydash::logged_val::value)
203-
.def("set_value", &pydash::logged_val::set_value)
204-
.def("name", &pydash::logged_val::name);
205-
206-
bind_type_glob_ref<pydash::logged_val>(m, "LV");
207205
bind_type_array<pydash::logged_val>(m, "LV");
208206

209-
210207
return m.ptr();
211208
}
212209

File renamed without changes.
File renamed without changes.

test/logval_array_test.py test/test_logval_array.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@
44

55
myid = pydash.myid().id()
66
nunits = pydash.nunits()
7+
78
# Collectively instantiate array:
89
array = pydash.ArrayLV(3 * nunits)
10+
911
# Initialize array:
10-
array[myid * 3 + 0] = { "first", myid };
11-
array[myid * 3 + 1] = { "second", myid };
12-
array[myid * 3 + 2] = { "third", myid };
12+
array[myid * 3 + 0] = pydash.LV(myid, "first")
13+
array[myid * 3 + 1] = pydash.LV(myid, "second")
14+
array[myid * 3 + 2] = pydash.LV(myid, "third")
15+
1316
# Wait for all units:
1417
pydash.barrier()
18+
1519
# Read array elements from remote unit:
1620
fromid = nunits - myid - 1
1721

0 commit comments

Comments
 (0)