-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Permit 2D _run output for backwards compatibility. #5014
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
Conversation
CC @daxfohl |
lgtm, thanks for cleaning up my mess! |
Is it possible to remove the |
There's still a bunch of other places that still use it (plus #5015, which is a similar issue), but maybe? v0.14 is coming up very soon - if we can't make the change before then, we could mark it as deprecated and remove it afterwards. |
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.
Some questions about mocking in tests, otherwise LGTM
cirq-core/cirq/sim/simulator_test.py
Outdated
@@ -101,6 +101,32 @@ def test_run_simulator_sweeps(): | |||
assert simulator._run.call_count == 2 | |||
|
|||
|
|||
@mock.patch.multiple(cirq.SimulatesSamples, __abstractmethods__=set(), _run=mock.Mock()) | |||
def test_run_simulator_sweeps_with_deprecated_run(): | |||
simulator = cirq.SimulatesSamples() |
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.
How hard would it be to create an actual simulator subclass for this test that has the deprecated _run
behavior? Mocking always feel rather brittle to me.
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.
This test is just a copy of test_run_simulator_sweeps
with _run
modified to return a 2D array, but it's not particularly expensive to remove mocking throughout this file - especially since Cirq on the whole seems to have moved away from mocking since this was written. I'll make the change.
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.
Removed some of the mocks. The intermediate state mocks are a fair bit more convoluted, so I've left them for now.
Fixes quantumlib#5000. This PR reinstates support for 2D measurement data from `_run`, but logs a warning if that path is used. External simulators will need to modify their `_run` implementation before v0.15.
Fixes quantumlib#5000. This PR reinstates support for 2D measurement data from `_run`, but logs a warning if that path is used. External simulators will need to modify their `_run` implementation before v0.15.
Fixes quantumlib#5000. This PR reinstates support for 2D measurement data from `_run`, but logs a warning if that path is used. External simulators will need to modify their `_run` implementation before v0.15.
Fixes #5000.
This PR reinstates support for 2D measurement data from
_run
, but logs a warning if that path is used. External simulators will need to modify their_run
implementation before v0.15.