@pytest.mark.parametrize('basis_state', [np.array([0, 0, 1, 0]), np.array([0, 0, 1, 0]), np.array([1, 0, 1, 0]), np.array([1, 1, 1, 1])])
def test_basis_state(self, device, basis_state, tol, skip_if):
    'Test basis state initialization.'
    n_wires = 4
    dev = device(n_wires)
    skip_if(dev, {'returns_probs': False})

    @qml.qnode(dev)
    def circuit():
        qml.BasisState(basis_state, wires=range(n_wires))
        return qml.probs(wires=range(n_wires))
    res = circuit()
    expected = np.zeros([(2 ** n_wires)])
    expected[np.ravel_multi_index(basis_state, ([2] * n_wires))] = 1
    assert np.allclose(res, expected, atol=tol(dev.shots))
Test basis state initialization.
@pytest.mark.parametrize('basis_state', [np.array([0, 0, 1, 0]), np.array([0, 0, 1, 0]), np.array([1, 0, 1, 0]), np.array([1, 1, 1, 1])])
def test_basis_state(self, device, basis_state, tol, skip_if):
    
    n_wires = 4
    dev = device(n_wires)
    skip_if(dev, {'returns_probs': False})

    @qml.qnode(dev)
    def circuit():
        qml.BasisState(basis_state, wires=range(n_wires))
        return qml.probs(wires=range(n_wires))
    res = circuit()
    expected = np.zeros([(2 ** n_wires)])
    expected[np.ravel_multi_index(basis_state, ([2] * n_wires))] = 1
    assert np.allclose(res, expected, atol=tol(dev.shots))