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

Fix issue with single parameter list #503

Merged
merged 3 commits into from Dec 8, 2020
Merged

Conversation

thisac
Copy link
Contributor

@thisac thisac commented Dec 7, 2020

Context:
eng.run(prog) crashes when attempting to use a single parameter list in the TDMProgram context.

Description of the Change:
A fix is added that changes a single free parameter to a list when only passing a single parameter list to the TDMProgram context.

Benefits:

The following now works:

prog = sf.TDMProgram(2)
eng = sf.Engine("gaussian")

with prog.context([1, 2]) as (p, q):
    ops.Sgate(p[0]) | q[0]
    ops.MeasureHomodyne(p[0]) | q[0]

eng.run(prog)

Possible Drawbacks:
None

Related GitHub Issues:
None

@thisac thisac self-assigned this Dec 7, 2020
@@ -144,6 +147,21 @@ def test_str_tdm_method():
assert prog.__str__() == "<TDMProgram: concurrent modes=1, time bins=0, spatial modes=0>"


def test_single_parameter_list_program():
Copy link
Collaborator

Choose a reason for hiding this comment

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

love the fact that you already got the testing!

@codecov
Copy link

codecov bot commented Dec 7, 2020

Codecov Report

Merging #503 (6d0163a) into master (75e3c26) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #503      +/-   ##
==========================================
+ Coverage   97.85%   97.86%   +0.01%     
==========================================
  Files          70       70              
  Lines        7313     7316       +3     
==========================================
+ Hits         7156     7160       +4     
+ Misses        157      156       -1     
Impacted Files Coverage Δ
strawberryfields/tdm/tdmprogram.py 95.67% <100.00%> (+0.62%) ⬆️

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 75e3c26...6d0163a. Read the comment docs.

@thisac thisac merged commit f6cb5e0 into master Dec 8, 2020
@thisac thisac deleted the tdm-single-parameter-array branch December 8, 2020 00:31
nquesada added a commit that referenced this pull request Jan 19, 2021
* Fix issue with single parameter list (#503)

* Fix issue with single parameter list

* Fix pyliny import complaint

* Update changelog

* removes unused variables in test_tdmprogram

* Fix run_options not being used (#500)

* Fix run_options not being used

* Update changelog

* Add tests

* removes unused variables in test_tdmprogram (#504)

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Add program code generator function (#496)

* Add serialize function

* Run black

* Remove f

* Updates from code review

* Improve operations handling

* Remove duplicate line

* Fix generate_code + add tests

* Tidy things up a bit

* Add forgotten factor

* Run black

* Update changelog

* Fixes from code review

* Update strawberryfields/io.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* change argument name

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Add wigner plotting (#495)

* Add wigner plotting to program

* Move plotting to plot module

* Remove numpy import

* Fixes after code-review

* Tidy up wigner plotting

* Run black

* Add test

* Update colours

* Update changelog

* rename tests

* Update strawberryfields/plot.py

Co-authored-by: antalszava <antalszava@gmail.com>

* add contours arg

* Update tests

* Update changelog

* Apply suggestions from code review

Co-authored-by: antalszava <antalszava@gmail.com>

* Remove url

* fix string

* fix arg name

Co-authored-by: antalszava <antalszava@gmail.com>

* Adds api_version property, adds 'Accept-Version' to headers (#512)

* Fock state and quadrature plotting  (#510)

* Fock state plotting draft

* Updates, error, test

* test & imports

* Test chart generation

* Formatting

* Remove unnecessary comment

* Two-mode test

* cutoff in test adjust

* quad and adjust fock prev chart

* Formatting

* Adjust

* quad test

* generate_quad_chart test

* Update tests/frontend/test_sf_plot.py

* update

* data always has two elements

* reset Makefile

* changelog, adjust chart title

* ket latex render

* latex in fock plot title

* adjust tests for latex

* Update strawberryfields/plot.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update strawberryfields/plot.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* adjust

* Update strawberryfields/plot.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* marginal

* Update strawberryfields/plot.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update strawberryfields/plot.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* docstring

* adjust tests for Fock

* quad tests

* docstring

* Move obtaining the Wigner function of the state to generate_wigner_chart

* Docstring

* add plot page

* Update strawberryfields/plot.py

Co-authored-by: Theodor <theodor@xanadu.ai>

* base state render

* docstring basestate render change

Co-authored-by: Josh Izaac <josh146@gmail.com>
Co-authored-by: Theodor <theodor@xanadu.ai>

* Fix bug in Dgate, Coherent, and DisplacedSqueezed (#507)

* Support TF tensors in batch form

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Add test

* Add to changelog

* Update PR in changelog

* New line

* Extend to other gates

* Update changelog

* Update

* Update test

* Update .github/CHANGELOG.md

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Fix typo

* Fix

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update tdm docstring (#519)

* removes unused variables in test_tdmprogram

* updates docstring

* Implement OAuth refresh token flow (#520)

* Implement OAuth refresh token flow

* Apply suggestions from code review

Formatting changes

Co-authored-by: antalszava <antalszava@gmail.com>

* Add correct token refresh path

* update path, update getting the access token, remove url wrapping in _request

* Formatting with black

* move dict init into func

* Updates

* refresh access token unit tests

* no print

* User request.post directly, update tests

* Wrapped request test, updates

* Updates

* Formatting

* Remove access token refreshing from init

* Update tests/api/test_connection.py

* Update tests/api/test_connection.py

* Update tests/api/test_connection.py

* Update tests/api/test_connection.py

* Update strawberryfields/api/connection.py

Co-authored-by: Jeremy Swinarton <jeremy@swinarton.com>

* update msg in test

* changelog

Co-authored-by: antalszava <antalszava@gmail.com>
Co-authored-by: Antal Szava <antalszava@example.com>
Co-authored-by: Jeremy Swinarton <jeremy@swinarton.com>

* Increment version number to v0.17.0 (#523)

* bump version and update changelog

* update about

* remove old current release

* minor tweaks

* dev bump (#524)

* Update photonic_hardware.rst (#526)

Co-authored-by: Theodor <theodor@xanadu.ai>
Co-authored-by: Josh Izaac <josh146@gmail.com>
Co-authored-by: antalszava <antalszava@gmail.com>
Co-authored-by: Jack Brown <jack@xanadu.ai>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Tim Leisti <corvust@users.noreply.github.com>
Co-authored-by: Antal Szava <antalszava@example.com>
Co-authored-by: Jeremy Swinarton <jeremy@swinarton.com>
nquesada added a commit that referenced this pull request Jan 20, 2021
* Fix issue with single parameter list (#503)

* Fix issue with single parameter list

* Fix pyliny import complaint

* Update changelog

* Fix run_options not being used (#500)

* Fix run_options not being used

* Update changelog

* Add tests

* removes unused variables in test_tdmprogram (#504)

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Add program code generator function (#496)

* Add serialize function

* Run black

* Remove f

* Updates from code review

* Improve operations handling

* Remove duplicate line

* Fix generate_code + add tests

* Tidy things up a bit

* Add forgotten factor

* Run black

* Update changelog

* Fixes from code review

* Update strawberryfields/io.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* change argument name

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Add wigner plotting (#495)

* Add wigner plotting to program

* Move plotting to plot module

* Remove numpy import

* Fixes after code-review

* Tidy up wigner plotting

* Run black

* Add test

* Update colours

* Update changelog

* rename tests

* Update strawberryfields/plot.py

Co-authored-by: antalszava <antalszava@gmail.com>

* add contours arg

* Update tests

* Update changelog

* Apply suggestions from code review

Co-authored-by: antalszava <antalszava@gmail.com>

* Remove url

* fix string

* fix arg name

Co-authored-by: antalszava <antalszava@gmail.com>

* Adds api_version property, adds 'Accept-Version' to headers (#512)

* Fock state and quadrature plotting  (#510)

* Fock state plotting draft

* Updates, error, test

* test & imports

* Test chart generation

* Formatting

* Remove unnecessary comment

* Two-mode test

* cutoff in test adjust

* quad and adjust fock prev chart

* Formatting

* Adjust

* quad test

* generate_quad_chart test

* Update tests/frontend/test_sf_plot.py

* update

* data always has two elements

* reset Makefile

* changelog, adjust chart title

* ket latex render

* latex in fock plot title

* adjust tests for latex

* Update strawberryfields/plot.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update strawberryfields/plot.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* adjust

* Update strawberryfields/plot.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* marginal

* Update strawberryfields/plot.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update strawberryfields/plot.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* docstring

* adjust tests for Fock

* quad tests

* docstring

* Move obtaining the Wigner function of the state to generate_wigner_chart

* Docstring

* add plot page

* Update strawberryfields/plot.py

Co-authored-by: Theodor <theodor@xanadu.ai>

* base state render

* docstring basestate render change

Co-authored-by: Josh Izaac <josh146@gmail.com>
Co-authored-by: Theodor <theodor@xanadu.ai>

* Fix bug in Dgate, Coherent, and DisplacedSqueezed (#507)

* Support TF tensors in batch form

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Add test

* Add to changelog

* Update PR in changelog

* New line

* Extend to other gates

* Update changelog

* Update

* Update test

* Update .github/CHANGELOG.md

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Fix typo

* Fix

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update tdm docstring (#519)

* removes unused variables in test_tdmprogram

* updates docstring

* Implement OAuth refresh token flow (#520)

* Implement OAuth refresh token flow

* Apply suggestions from code review

Formatting changes

Co-authored-by: antalszava <antalszava@gmail.com>

* Add correct token refresh path

* update path, update getting the access token, remove url wrapping in _request

* Formatting with black

* move dict init into func

* Updates

* refresh access token unit tests

* no print

* User request.post directly, update tests

* Wrapped request test, updates

* Updates

* Formatting

* Remove access token refreshing from init

* Update tests/api/test_connection.py

* Update tests/api/test_connection.py

* Update tests/api/test_connection.py

* Update tests/api/test_connection.py

* Update strawberryfields/api/connection.py

Co-authored-by: Jeremy Swinarton <jeremy@swinarton.com>

* update msg in test

* changelog

Co-authored-by: antalszava <antalszava@gmail.com>
Co-authored-by: Antal Szava <antalszava@example.com>
Co-authored-by: Jeremy Swinarton <jeremy@swinarton.com>

* Increment version number to v0.17.0 (#523)

* bump version and update changelog

* update about

* remove old current release

* minor tweaks

* dev bump (#524)

* Update photonic_hardware.rst (#526)

* dummy change

* Update strawberryfields/backends/bosonicbackend/backend.py

Co-authored-by: Theodor <theodor@xanadu.ai>
Co-authored-by: Josh Izaac <josh146@gmail.com>
Co-authored-by: antalszava <antalszava@gmail.com>
Co-authored-by: Jack Brown <jack@xanadu.ai>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Tim Leisti <corvust@users.noreply.github.com>
Co-authored-by: Antal Szava <antalszava@example.com>
Co-authored-by: Jeremy Swinarton <jeremy@swinarton.com>
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.

None yet

3 participants