class_docstr: Test the state_vector() method of QutritBasisState operation.
class_docstr_tok: ["Test","the","state_vector","(",")","method","of","QutritBasisState","operation","."]
docstr: Tests that QutritBasisState state_vector returns kets as expected.
docstr_tok: ["Tests","that","QutritBasisState","state_vector","returns","kets","as","expected","."]
code: def test_QutritBasisState_state_vector(
      self, num_wires, wire_order, one_position
  ):
      """Tests that QutritBasisState state_vector returns kets as expected."""
      basis_op = qml.QutritBasisState([0, 1], wires=[1, 2])
      ket = basis_op.state_vector(wire_order=wire_order)
      assert qml.math.shape(ket) == (3,) * num_wires
      assert ket[one_position] == 1
      ket[
          one_position
      ] = 0  # everything else should be zero, as we assert below
      assert np.allclose(np.zeros((3,) * num_wires), ket)
  
file_path: pennylane/tests/ops/qutrit/test_qutrit_state_prep.py
imports: import pytest
  import pennylane
  from pennylane import numpy
  from pennylane.wires import WireError
label_desc: Use image node_id 1 for calling the TestStateVector obj's underlying member method code with example usage: obj.test_QutritBasisState_state_vector(num_wires, wire_order, one_position) without return types