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

Use defaultdict where possible #533

Merged
merged 2 commits into from
May 31, 2020

Conversation

jstoja
Copy link

@jstoja jstoja commented Apr 11, 2020

Description of proposed changes

Use defaultdict where possible

Testing

What steps should be taken to test the changes you've proposed? Automated tests should be enough.
If you added or changed behavior in the codebase, did you update the tests, or do you need help with this? -> didn't change behaviour, only simplified the code.

@codecov
Copy link

codecov bot commented Apr 11, 2020

Codecov Report

Merging #533 into master will increase coverage by 0.52%.
The diff coverage is 22.22%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #533      +/-   ##
==========================================
+ Coverage   18.68%   19.21%   +0.52%     
==========================================
  Files          31       31              
  Lines        5053     5070      +17     
  Branches     1281     1286       +5     
==========================================
+ Hits          944      974      +30     
+ Misses       4082     4073       -9     
+ Partials       27       23       -4     
Impacted Files Coverage Δ
augur/import_beast.py 7.11% <20.00%> (+0.36%) ⬆️
augur/clades.py 12.37% <25.00%> (+1.03%) ⬆️
augur/titer_model.py 18.61% <0.00%> (-0.30%) ⬇️
augur/utils.py 22.89% <0.00%> (-0.18%) ⬇️
augur/frequency_estimators.py 33.71% <0.00%> (-0.13%) ⬇️
augur/refine.py 5.52% <0.00%> (+0.49%) ⬆️
augur/mask.py 100.00% <0.00%> (+13.63%) ⬆️

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 9ed6f80...ea0f10e. Read the comment docs.

@groutr
Copy link
Contributor

groutr commented May 12, 2020

You should probably set the default_factory to None after adding all your items to the defaultdict. Otherwise, future lookups to non-existent keys will create the key instead of raising a KeyError.

@jstoja
Copy link
Author

jstoja commented May 13, 2020

Thanks @groutr , that's a very good remark!

@rneher rneher self-requested a review May 31, 2020 08:39
@rneher rneher merged commit f50e8f0 into nextstrain:master May 31, 2020
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