Skip to content

Commit

Permalink
Added __iter__() and keys() to BaseGroup python binding
Browse files Browse the repository at this point in the history
* Made it possible to iterate over all of a BaseGroup's children

Signed-off-by: Jared Duffey <[email protected]>
  • Loading branch information
JDuffeyBQ committed Dec 6, 2024
1 parent ed349fd commit 444a351
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,8 @@ PYBIND11_MODULE(simplnx, mod)
baseGroup.def("contains", py::overload_cast<const std::string&>(&BaseGroup::contains, py::const_));
baseGroup.def("__getitem__", py::overload_cast<const std::string&>(&BaseGroup::at), py::return_value_policy::reference_internal);
baseGroup.def("__len__", &BaseGroup::getSize);
baseGroup.def("__iter__", [](BaseGroup& self) { return py::make_iterator(self.begin(), self.end()); });
baseGroup.def("keys", [](const BaseGroup& self) { return self.getDataMap().getNames(); });

auto baseGroupType = py::enum_<BaseGroup::GroupType>(baseGroup, "GroupType");
baseGroupType.value("BaseGroup", BaseGroup::GroupType::BaseGroup);
Expand Down

0 comments on commit 444a351

Please sign in to comment.