Skip to content
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

Add option to disable cut_edges updater with use_cut_edges flag #375

Merged
merged 1 commit into from Jan 10, 2022

Conversation

InnovativeInventor
Copy link
Member

@InnovativeInventor InnovativeInventor commented Jan 6, 2022

This is a PR broken out from #372 to ease the code review process.

As noted in #368, the cut_edges updater is forcibly enabled by default for every Partition object. However, the user has no way of opting out of this expensive updater. Prior to pcompress, this wasn't a big deal. However, now that GerryChain runs are replayable (and since most analysis is now done with replayable chains), it doesn't make sense to force every partition to calculate the cut_edges updater.

As an example case where this would be useful, let's say that we want to draw election histograms or simply export a few sample maps in a recorded chain run (a fairly common occurrence). In this case, there would be no need to calculate the cut_edges and disabling the updater by providing the use_cut_edges flag would result in a significant speedup.

Note that this PR is backwards compatible. By default, cut_edges are calculated (use_cut_edges defaults to True and is an optional argument).

Fixes #368

@InnovativeInventor
Copy link
Member Author

For some context, my replay speeds are roughly 1260 it/s (3-4x speedup) with this flag set to False. I'm open to renaming the flag name, if it seems unwieldy.

Copy link
Member

@pizzimathy pizzimathy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A small tweak and a possible change, and I think this is ready to go!

gerrychain/partition/partition.py Show resolved Hide resolved
gerrychain/partition/partition.py Show resolved Hide resolved
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.

Provide a way for a user to opt-out of the cut_edges updater (for replays)
2 participants