Skip to content

Commit

Permalink
Improve the rendering of enums in the documentation (colmap#2966)
Browse files Browse the repository at this point in the history
  • Loading branch information
sarlinpe authored Nov 29, 2024
1 parent 256639d commit e778be6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/pycolmap/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ void AddStringToEnumConstructor(py::enum_<T>& enm) {
enm.def(py::init([enm](const std::string& value) {
return PyStringToEnum(enm, py::str(value)); // str constructor
}),
"value"_a);
"name"_a);
enm.attr("__repr__") = enm.attr("__str__");
py::implicitly_convertible<std::string, T>();
}

Expand Down
7 changes: 4 additions & 3 deletions src/pycolmap/scene/two_view_geometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ using namespace pybind11::literals;
namespace py = pybind11;

void BindTwoViewGeometryScene(py::module& m) {
py::enum_<TwoViewGeometry::ConfigurationType>(m,
"TwoViewGeometryConfiguration")
.value("UNDEFINED", TwoViewGeometry::UNDEFINED)
py::enum_<TwoViewGeometry::ConfigurationType> PyTwoViewGeometryConfiguration(
m, "TwoViewGeometryConfiguration");
PyTwoViewGeometryConfiguration.value("UNDEFINED", TwoViewGeometry::UNDEFINED)
.value("DEGENERATE", TwoViewGeometry::DEGENERATE)
.value("CALIBRATED", TwoViewGeometry::CALIBRATED)
.value("UNCALIBRATED", TwoViewGeometry::UNCALIBRATED)
Expand All @@ -27,6 +27,7 @@ void BindTwoViewGeometryScene(py::module& m) {
.value("PLANAR_OR_PANORAMIC", TwoViewGeometry::PLANAR_OR_PANORAMIC)
.value("WATERMARK", TwoViewGeometry::WATERMARK)
.value("MULTIPLE", TwoViewGeometry::MULTIPLE);
AddStringToEnumConstructor(PyTwoViewGeometryConfiguration);

py::class_<TwoViewGeometry> PyTwoViewGeometry(m, "TwoViewGeometry");
PyTwoViewGeometry.def(py::init<>())
Expand Down

0 comments on commit e778be6

Please sign in to comment.