Skip to content

pybind: pos validation and class attribute constants for S2CellId bindings#625

Open
deustis wants to merge 2 commits into
google:masterfrom
deustis:deustis/s2cell_id_binding_fixes
Open

pybind: pos validation and class attribute constants for S2CellId bindings#625
deustis wants to merge 2 commits into
google:masterfrom
deustis:deustis/s2cell_id_binding_fixes

Conversation

@deustis
Copy link
Copy Markdown
Contributor

@deustis deustis commented May 12, 2026

Summary

  • Add S2CellId::kMaxPosition constant (2^61 - 1) to s2cell_id.h with a C++ unit test verifying valid and overflow behavior
  • Validate pos argument in S2CellId.from_face_pos_level Python binding; expose MAX_POSITION as a Python class attribute
  • Switch Python binding constants to cls.attr() pattern for uniform style regardless of whether constants come from static constexpr members or enum values; document in README
  • Fix BUILD: add missing @abseil-cpp//absl/strings dep to s2cell_id_bindings

- Add S2CellId::kMaxPosition constant (2^61 - 1) to s2cell_id.h and
  add C++ unit test verifying valid/overflow behavior
- Validate pos argument in from_face_pos_level; expose MAX_POSITION
  as a Python class attribute; add Python test for pos out of range
- Switch constants to cls.attr() pattern; update README to document
  this style
- Fix BUILD: add @abseil-cpp//absl/strings dep to s2cell_id_bindings
@deustis
Copy link
Copy Markdown
Contributor Author

deustis commented May 12, 2026

@jmr, couple of fast follow improvements here to be able to validate the position attribute, and I also found a way to use python class attributes for constants as you had suggested previously.

@deustis deustis changed the title pybind: Address review comments on S2CellId bindings pybind: pos validation and class attribute constants for S2CellId bindings May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant