Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion python/csrc/pylayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ void bind_layout(py::module &m) {

py::class_<snap::LayoutImpl, snap::Layout>(m, "Layout")
.def(py::init<snap::LayoutOptions>(), py::arg("options"))
.def_readonly("options", &snap::LayoutImpl::options)
.def("__repr__",
[](const snap::LayoutImpl &self) {
std::stringstream ss;
Expand All @@ -66,6 +67,10 @@ void bind_layout(py::module &m) {
std::shared_ptr<snap::SlabLayoutImpl>>(m, "SlabLayout");

pySlabLayout.def(py::init<snap::LayoutOptions>(), py::arg("options"))
.def_readonly("options", &snap::SlabLayoutImpl::options)
.def("rank_of", &snap::SlabLayoutImpl::rank_of)
.def("loc_of", &snap::SlabLayoutImpl::loc_of)
.def("neighbor_rank", &snap::SlabLayoutImpl::neighbor_rank)
.def("__repr__", [](const snap::SlabLayoutImpl &self) {
std::stringstream ss;
self.pretty_print(ss);
Expand All @@ -86,7 +91,11 @@ void bind_layout(py::module &m) {
std::shared_ptr<snap::CubedLayoutImpl>>(m, "CubedLayout");

pyCubedLayout.def(py::init<snap::LayoutOptions>(), py::arg("options"))
.def("__repr__", [](const snap::CubedSphereLayoutImpl &self) {
.def_readonly("options", &snap::CubedLayoutImpl::options)
.def("rank_of", &snap::CubedLayoutImpl::rank_of)
.def("loc_of", &snap::CubedLayoutImpl::loc_of)
.def("neighbor_rank", &snap::CubedLayoutImpl::neighbor_rank)
.def("__repr__", [](const snap::CubedLayoutImpl &self) {
std::stringstream ss;
self.pretty_print(ss);
return fmt::format("CubedSphereLayout(\n{})", ss.str());
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The repr method for CubedLayout incorrectly returns a string labeled as "CubedSphereLayout". It should return "CubedLayout" instead to match the actual class name. This inconsistency could confuse users when inspecting CubedLayout objects.

Suggested change
return fmt::format("CubedSphereLayout(\n{})", ss.str());
return fmt::format("CubedLayout(\n{})", ss.str());

Copilot uses AI. Check for mistakes.
Expand All @@ -108,6 +117,10 @@ void bind_layout(py::module &m) {

pyCubedSphereLayout.def(py::init<>())
.def(py::init<snap::LayoutOptions>(), py::arg("options"))
.def_readonly("options", &snap::CubedSphereLayoutImpl::options)
.def("rank_of", &snap::CubedSphereLayoutImpl::rank_of)
.def("loc_of", &snap::CubedSphereLayoutImpl::loc_of)
.def("neighbor_rank", &snap::CubedSphereLayoutImpl::neighbor_rank)
.def("__repr__", [](const snap::CubedSphereLayoutImpl &self) {
std::stringstream ss;
self.pretty_print(ss);
Expand Down
Loading