Pairing functions and minor utils/typing/doc fixes - #167
Merged
Conversation
Member
Author
|
As is the case with #166, I plan to merge this PR ASAP, preferably by the end of the week. My git history is somewhat tangled, and squash-merging these into main will help me prepare the ultimate update that both these PRs lead to. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
This PR introduces a few small technical improvements to instamatic utilities and adds a new module to
instamatic.utils:pairingwhich implements pairing functions based on the ulam spiral (regular and hexagonal variant). The changes are mostly typing or documentation fixes, as well as a newclosedattribute added topairwisefunction that allows yielding the last-first pair of points alongside others:The four new functions (two plus inverse functions) in the
pairingmodule include:ulam2ij(n): return coordinates of n-th point on regular Ulam spiral;ij2ulam(i, j): return regular Ulam index of point (i, j) in orthogonal 2D space;hulam2uv(n): return coordinates of n-th point on a hexagonal Ulam spiral;uv2hulam(u, v): return hexagonal Ulam index of point (u, v) in hexagonal 2D space.The hexagonal space is indexed using a "hulam" pairing, ulam spiral analogue, defined as: x axis right, y axis 60 degrees anticlockwise. Both function pairs allow for easy iterating over 2D space points (grid windows or measurement locations) on the grid space using natural numbers. The documentation of individual functions is sparse, because most of their docs is common to all of them and resides in the module
__doc__. For human eye, the role of this module is best explained using the example from theif __name__ == "__main__"block:The new functionality introduced here is not used by the current version of instamatic. It may seem controversial, but I have a large update that I would like to publish in October. I decided to publish this smaller update in preparation to the large publication, so that in each pull request, the review focus may remain on the main subject.
Changes
pairwise.py: Added two Z^2 <–> N_0 pairing bijections ininstamatic.utils;test_utils.pt: Added tests for all new functions frompairwise.py;iterating.py: Addedcloseargument topairwiseto yield "last, first" pair;controller.py: Fixedctrl.get_movietype hint and documentation;_typing.py: Addedfloat_nmannotated type for when distance is expressed as float.