Closed svenkreiss closed 8 years ago
A few comments. At a higher level, do we want to preserve the 1↔1 mapping between C++ and Python classes? If so, walk
and walk_fast
should be provided in a separate module.
Review status: 0 of 3 files reviewed at latest revision, 4 unresolved discussions.
s2sphere/sphere.py, line 1139 [r1] (raw file):
Iterator over instances of :class:`CellId`s. """ cellid = cls.begin(level).id()
Python question: why do cls.begin
rather than CellId.begin
?
_s2sphere/sphere.py, line 1139 [r1] (raw file):_
Iterator over instances of :class:`CellId`s. """ cellid = cls.begin(level).id()
The naming here is a bit confusing -- is cellid
a CellId
or an int
?
s2sphere/sphere.py, line 1141 [r1] (raw file):
cellid = cls.begin(level).id() endid = cls.end(level).id() increment = cls.begin(level).lsb() << 1
This is cryptic; add a comment (also in walk_fast
)
s2sphere/sphere.py, line 1154 [r1] (raw file):
Use with caution: This modifies the underlying ``id`` of a single :class:`CellId` instance for performance reasons.
I'd rewrite this comment to be more oriented towards a user of this function (and less about implementation details). For instance, something like
Use with caution: this repeatedly yields mutates a single object with a changing ``id``.
If you save the object, it will change out from underneath you.
Comments from Reviewable
Thanks for the comments.
That 1 to 1 mapping never existed. This was one of the comments from the original author that he regretted not having preserved that better.
Review status: 0 of 3 files reviewed at latest revision, 4 unresolved discussions.
s2sphere/sphere.py, line 1139 [r1] (raw file):
This has something to do with the behavior for derived classes. I had never used it like this before (I usually use
@staticmethod
and not@classmethod
), but I think it could make sense so thatbegin
is called of the derived class in case it is overwritten.
_s2sphere/sphere.py, line 1139 [r1] (raw file):_
an
int
. I am struggling to come up with a better name.
s2sphere/sphere.py, line 1141 [r1] (raw file):
Done.
s2sphere/sphere.py, line 1154 [r1] (raw file):
Done.
Comments from Reviewable
Some more suggestions for the comments, otherwise
Review status: 0 of 3 files reviewed at latest revision, 3 unresolved discussions.
_s2sphere/sphere.py, line 1139 [r1] (raw file):_
cell_id_int
?
s2sphere/sphere.py, line 1141 [r1] (raw file):
This still wasn't clear to me... @svenkreiss and I hashed it out. How about something like this?
The 64-bit ID has:
- 3 bits to encode the face
- 0-60 bits to encode the position
- a 1
The final 1 is the least significant bit. Doubling it yields the increment between positions as 64-bit IDs.
_s2sphere/sphere.py, line 1154 [r1] (raw file):_
You've got "use with caution" twice.
Comments from Reviewable
Review status: 0 of 3 files reviewed at latest revision, 1 unresolved discussion.
s2sphere/sphere.py, line 1154 [r1] (raw file):
Done.
Comments from Reviewable
:shipit:
Review status: 0 of 3 files reviewed at latest revision, all discussions resolved.
Comments from Reviewable
more pythonic iterator over cells at a given level
This change is