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

Remove unused method SimulationState.with_qubits #5748

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions cirq-core/cirq/sim/density_matrix_simulation_state_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,6 @@ class NoDetails:
cirq.act_on(NoDetails(), args, qubits=())


def test_with_qubits():
original = cirq.DensityMatrixSimulationState(
qubits=cirq.LineQubit.range(1), initial_state=1, dtype=np.complex64
)
extened = original.with_qubits(cirq.LineQubit.range(1, 2))
np.testing.assert_almost_equal(
extened.target_tensor,
cirq.density_matrix_kronecker_product(
np.array([[0, 0], [0, 1]], dtype=np.complex64),
np.array([[1, 0], [0, 0]], dtype=np.complex64),
),
)


def test_qid_shape_error():
with pytest.raises(ValueError, match="qid_shape must be provided"):
cirq.sim.density_matrix_simulation_state._BufferedDensityMatrix.create(initial_state=0)
Expand Down
21 changes: 0 additions & 21 deletions cirq-core/cirq/sim/simulation_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,27 +173,6 @@ def kronecker_product(self: TSelf, other: TSelf, *, inplace=False) -> TSelf:
args._set_qubits(self.qubits + other.qubits)
return args

def with_qubits(self: TSelf, qubits) -> TSelf:
"""Extend current state space with added qubits.

The state of the added qubits is the default value set in the
subclasses. A new state space is created as the Kronecker product of
the original one and the added one.

Args:
qubits: The qubits to be added to the state space.

Returns:
A new subclass object containing the extended state space.
"""
# TODO(#5721): Fix inconsistent usage of the `state` argument in the
# SimulationState base (required) and in its derived classes (unknown
# in StateVectorSimulationState), then remove the pylint filter below.
# pylint: disable=missing-kwoa
new_space = type(self)(qubits=qubits) # type: ignore
# pylint: enable=missing-kwoa
return self.kronecker_product(new_space)

def factor(
self: TSelf, qubits: Sequence['cirq.Qid'], *, validate=True, atol=1e-07, inplace=False
) -> Tuple[TSelf, TSelf]:
Expand Down
14 changes: 0 additions & 14 deletions cirq-core/cirq/sim/state_vector_simulation_state_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,20 +269,6 @@ def test_measured_mixture():
assert results.histogram(key='flip') == results.histogram(key='m')


def test_with_qubits():
original = cirq.StateVectorSimulationState(
qubits=cirq.LineQubit.range(2), initial_state=1, dtype=np.complex64
)
extened = original.with_qubits(cirq.LineQubit.range(2, 4))
np.testing.assert_almost_equal(
extened.target_tensor,
cirq.state_vector_kronecker_product(
np.array([[0.0 + 0.0j, 1.0 + 0.0j], [0.0 + 0.0j, 0.0 + 0.0j]], dtype=np.complex64),
np.array([[1.0 + 0.0j, 0.0 + 0.0j], [0.0 + 0.0j, 0.0 + 0.0j]], dtype=np.complex64),
),
)


def test_qid_shape_error():
with pytest.raises(ValueError, match="qid_shape must be provided"):
cirq.sim.state_vector_simulation_state._BufferedStateVector.create(initial_state=0)