Skip to content

Commit

Permalink
replace qubit_state_vector -> state_prep
Browse files Browse the repository at this point in the history
  • Loading branch information
andrijapau committed Nov 13, 2024
1 parent a8b2ef0 commit 0c8ba8b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions pennylane_cirq/cirq_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def _apply_basis_state(self, basis_state_operation):
raise NotImplementedError

@abc.abstractmethod
def _apply_qubit_state_vector(self, qubit_state_vector_operation):
def _apply_state_prep(self, state_prep_operation):
"""Apply a state vector preparation.
Args:
Expand Down Expand Up @@ -284,7 +284,7 @@ def apply(self, operations, **kwargs):
if operation.name == "BasisState":
self._apply_basis_state(operation)
elif operation.name == "StatePrep":
self._apply_qubit_state_vector(operation)
self._apply_state_prep(operation)
else:
self._apply_operation(operation)

Expand Down
8 changes: 4 additions & 4 deletions pennylane_cirq/simulator_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ def _apply_basis_state(self, basis_state_operation):

self._initial_state = basis_state_operation.state_vector(wire_order=self.wires).flatten()

def _apply_qubit_state_vector(self, qubit_state_vector_operation):
def _apply_state_prep(self, state_prep_operation):
# pylint: disable=missing-function-docstring
if self.shots is not None:
raise qml.DeviceError("The operator StatePrep is only supported in analytic mode.")

self._initial_state = qubit_state_vector_operation.state_vector(
self._initial_state = state_prep_operation.state_vector(
wire_order=self.wires
).flatten()

Expand Down Expand Up @@ -270,8 +270,8 @@ def _apply_basis_state(self, basis_state_operation):
super()._apply_basis_state(basis_state_operation)
self._initial_state = self._convert_to_density_matrix(self._initial_state)

def _apply_qubit_state_vector(self, qubit_state_vector_operation):
super()._apply_qubit_state_vector(qubit_state_vector_operation)
def _apply_state_prep(self, state_prep_operation):
super()._apply_state_prep(state_prep_operation)
self._initial_state = self._convert_to_density_matrix(self._initial_state)

def _convert_to_density_matrix(self, state_vec):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test_basis_state(self, shots, tol, state):
expected[np.ravel_multi_index(state, [2] * 4)] = 1
assert np.allclose(res, expected, **tol)

def test_qubit_state_vector(self, init_state, shots, tol):
def test_state_prep(self, init_state, shots, tol):
"""Test PauliX application"""
dev = SimulatorDevice(1, shots=shots)
state = init_state(1)
Expand Down Expand Up @@ -288,7 +288,7 @@ def test_identity_basis_state(self, shots, tol):
expected = np.kron(expected, expected.conj()).reshape([16, 16])
assert np.allclose(res, expected, **tol)

def test_qubit_state_vector(self, init_state, shots, tol):
def test_state_prep(self, init_state, shots, tol):
"""Test PauliX application"""
dev = MixedStateSimulatorDevice(1, shots=shots)
state = init_state(1)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_mixed_simulator_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ def test_basis_state_not_at_beginning_error(self, simulator_device_1_wire):
):
simulator_device_1_wire.apply([qml.PauliX(0), qml.BasisState(np.array([0]), wires=[0])])

def test_qubit_state_vector_not_at_beginning_error(self, simulator_device_1_wire):
def test_state_prep_not_at_beginning_error(self, simulator_device_1_wire):
"""Tests that application of StatePrep raises an error if is not
the first operation."""

Expand Down Expand Up @@ -474,7 +474,7 @@ def test_basis_state_not_analytic_error(self, simulator_device_1_wire):
):
simulator_device_1_wire.apply([qml.BasisState(np.array([0]), wires=[0])])

def test_qubit_state_vector_not_analytic_error(self, simulator_device_1_wire):
def test_state_prep_not_analytic_error(self, simulator_device_1_wire):
"""Tests that application of StatePrep raises an error if the device
is not in analytic mode."""

Expand Down
4 changes: 2 additions & 2 deletions tests/test_simulator_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ def test_basis_state_not_at_beginning_error(self, simulator_device_1_wire):
):
simulator_device_1_wire.apply([qml.PauliX(0), qml.BasisState(np.array([0]), wires=[0])])

def test_qubit_state_vector_not_at_beginning_error(self, simulator_device_1_wire):
def test_state_prep_not_at_beginning_error(self, simulator_device_1_wire):
"""Tests that application of StatePrep raises an error if is not
the first operation."""

Expand Down Expand Up @@ -500,7 +500,7 @@ def test_basis_state_not_analytic_error(self, simulator_device_1_wire):
):
simulator_device_1_wire.apply([qml.BasisState(np.array([0]), wires=[0])])

def test_qubit_state_vector_not_analytic_error(self, simulator_device_1_wire):
def test_state_prep_not_analytic_error(self, simulator_device_1_wire):
"""Tests that application of StatePrep raises an error if the device
is not in analytic mode."""

Expand Down

0 comments on commit 0c8ba8b

Please sign in to comment.