-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Iterator APIs (via ResumableFunctions.jl) #121
Conversation
Although this is a breaking change, this brings GerryChain Julia more in line with GerryChain Python and allows the user to save and export state more easily. This API is different from the one proposed in #94 in that it returns a Partition object and the scores.
The iterators are now exposed in `recom_chain_iter` and `flip_chain_iter` respectively to avoid any breaking changes.
For some more context, I decided to not break backwards compatibility and made |
a678eb6#diff-ade2663ea888449e8028f941e69e33ec7f16635c54248240974af0ea18ffe682R288 is a long line, but it is necessary since I can't add it to the multi-line comment above and the workaround itself is finnicky. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am the original author of most of these changes (over in #94), and I've run a bunch of chains this way—it works! However, would love a review from other folks just to make sure I didn't miss any subtle ordering issues, etc.
Yep, this is a fairly simple, but impactful change (it really changes up the internals), that should hopefully maintain backwards compatibility. I've tested it with my scripts, etc. and it appears to work -- more testing and eyeballs would be better. Finally, as this change is a minor but backwards-compatible change, the minor version number should be bumped up as per semantic versioning (e.g. |
Actually, I just spotted an issue here: the semantics of the iterator are different from the Python version of GerryChain, which may confuse our users. Specifically,
|
I'm mostly in favor of adding a note about this slight divergence from GerryChain Python in the docs for a few reasons. Firstly, I'm not quite sure when/how often someone would want a copy of the partition object outside the for loop (I've certainly never had to do that) -- even then, it should be fairly easy to detect that all the copies one is storing are the same. Secondly, changing the behavior to be less speedy (by default) undercuts the only selling point of GerryChain Julia: speed. I don't think we should compromise on that, especially with the defaults. So, I'm not sure if we're sabotaging our performance out of concern for a phantom use case. I do like the third idea (however, it doesn't really answer whether we should copy the partition by default). What do others think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!!! Glad that we have this option. I wish there were a cleaner way to name the functions besides just adding _iter
but that's not, like, a fixable thing afaik. 👍 thank you @InnovativeInventor for this!
Since #94 was stagnating, I decided to break out the iterator-style API into this PR using ResumableFunctions.jl.
Caveat: The API exposed by this PR is different from the one proposed in #94. Rather than just returning scores, it also returns the
Partition
object as well in a tuple. This makes it more versatile.