-
Notifications
You must be signed in to change notification settings - Fork 71
Fix dropped state collapse in FreeQuantumState.measure_multiple #355
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
base: RnD
Are you sure you want to change the base?
Changes from all commits
8a301fa
ef4bdc4
5e69bd6
7b3d075
9635298
988b1f1
03df443
e26af95
ef06557
d135e9f
d7041a3
6719676
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,6 +80,27 @@ def test_measure_multiple(): | |
| assert Photon.measure_multiple(basis, [photon1, photon2], rng) == 0 | ||
|
|
||
|
|
||
| def test_measure_multiple_collapses_state(): | ||
| """After measure_multiple, the shared FreeQuantumState must collapse to the | ||
| measured basis vector (and stay shared between the entangled photons).""" | ||
| tl = Timeline() | ||
| photon1 = Photon("p1", tl, quantum_state=(complex(2 ** -0.5), complex(2 ** -0.5))) | ||
| photon2 = Photon("p2", tl, quantum_state=(complex(2 ** -0.5), complex(2 ** -0.5))) | ||
| photon1.combine_state(photon2) | ||
|
|
||
| basis = ((complex(1), complex(0), complex(0), complex(0)), | ||
| (complex(0), complex(1), complex(0), complex(0)), | ||
| (complex(0), complex(0), complex(1), complex(0)), | ||
| (complex(0), complex(0), complex(0), complex(1))) | ||
|
|
||
| res = Photon.measure_multiple(basis, [photon1, photon2], np.random.default_rng(0)) | ||
|
|
||
| expected = tuple(complex(1) if i == res else complex(0) for i in range(4)) | ||
| assert tuple(photon1.quantum_state.state) == expected, "state did not collapse to measured basis vector" | ||
| # both photons must keep sharing the same collapsed state object | ||
| assert photon1.quantum_state.state is photon2.quantum_state.state | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be good to add assertions preventing these invalid class attributes from being used. |
||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You check that state is shared but we should also check that entanglement_states is also shared |
||
| def test_add_loss(): | ||
| tl = Timeline() | ||
| photon = Photon("", tl, encoding_type=single_atom) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please call this quantum_state. Avoid abbreviations when able.