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

Cache flow_from_changes #384

Merged
merged 1 commit into from
Feb 11, 2022
Merged

Conversation

InnovativeInventor
Copy link
Member

This is a PR broken out from #372 to ease the code review process. These sets of PRs are the second and final batch -- after every PR from this batch is merged in, the entire perf-tuning branch will be considered fully merged in and done.

@codecov-commenter
Copy link

Codecov Report

Merging #384 (faea096) into main (8acd44c) will decrease coverage by 0.01%.
The diff coverage is 94.28%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #384      +/-   ##
==========================================
- Coverage   88.17%   88.16%   -0.02%     
==========================================
  Files          37       37              
  Lines        1666     1664       -2     
==========================================
- Hits         1469     1467       -2     
  Misses        197      197              
Impacted Files Coverage Δ
gerrychain/grid.py 73.49% <0.00%> (ø)
gerrychain/proposals/tree_proposals.py 27.27% <50.00%> (ø)
gerrychain/constraints/contiguity.py 96.59% <100.00%> (ø)
gerrychain/metagraph.py 94.44% <100.00%> (ø)
gerrychain/partition/assignment.py 95.89% <100.00%> (-0.11%) ⬇️
gerrychain/partition/partition.py 98.76% <100.00%> (ø)
gerrychain/proposals/proposals.py 97.67% <100.00%> (ø)
gerrychain/proposals/spectral_proposals.py 87.50% <100.00%> (ø)
gerrychain/updaters/compactness.py 97.72% <100.00%> (ø)
gerrychain/updaters/county_splits.py 100.00% <100.00%> (ø)
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8acd44c...faea096. Read the comment docs.

@pizzimathy pizzimathy self-requested a review January 19, 2022 21:00
@InnovativeInventor InnovativeInventor force-pushed the perf-cache-flows-from-changes branch from faea096 to 8509a45 Compare February 10, 2022 19:57
@InnovativeInventor InnovativeInventor force-pushed the perf-cache-flows-from-changes branch from 8509a45 to ae65596 Compare February 11, 2022 01:32
Copy link
Contributor

@gabeschoenbach gabeschoenbach left a comment

Choose a reason for hiding this comment

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

This all makes sense, my one question is in the new assignment of self.flows at line 81:

self.flows = flows_from_changes(parent, self)  # careful

self here refers to the partition, yes? It's okay to not be the first parameter? I see that when it's called in line 111 of tally.py you explicitly pass in a partition, so I guess I'm wondering why it necessarily needs to be called self in the first place.

@InnovativeInventor
Copy link
Member Author

Dicts can't be hashed in Python (so it can't be cached if a flips object is passed, which was the original behavior). Partitions, on the other hand, can.

@InnovativeInventor InnovativeInventor merged commit e818a5a into main Feb 11, 2022
@InnovativeInventor InnovativeInventor deleted the perf-cache-flows-from-changes branch May 24, 2022 16:06
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.

3 participants