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

Replace pop with indexing in reshape_samples #548

Merged
merged 1 commit into from
Feb 26, 2021

Conversation

thisac
Copy link
Contributor

@thisac thisac commented Feb 25, 2021

Context:
The reshape_samples function in tdmprogram.py currently works by popping elements from the all_samples dictionary that's being sent in as an argument, and then inserting them into a new dictionary which is then returned. This causes the sent in all_samples dictionary to be empty after having reshaped the samples (which might be confusing for the user, since this is nowhere stated).

This is not really an optimal way of handling things, and should probably be fixed.

Description of the Change:
The popping of samples from the input all_samples dictionary is changed to indexing, while keeping track of used indices. Thanks to @lneuhaus for pointing this out!

Benefits:
This method doesn't change the input all_samples and it should be equally fast as before, if not faster.

Possible Drawbacks:
None

Related GitHub Issues:
None

@codecov
Copy link

codecov bot commented Feb 25, 2021

Codecov Report

Merging #548 (8fb32dc) into master (9ee646f) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #548   +/-   ##
=======================================
  Coverage   98.19%   98.19%           
=======================================
  Files          76       76           
  Lines        8327     8329    +2     
=======================================
+ Hits         8177     8179    +2     
  Misses        150      150           
Impacted Files Coverage Δ
strawberryfields/tdm/tdmprogram.py 95.72% <100.00%> (+0.04%) ⬆️

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 9ee646f...8fb32dc. Read the comment docs.

Copy link
Collaborator

@lneuhaus lneuhaus left a comment

Choose a reason for hiding this comment

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

Great! Nothing to add here.

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.

2 participants