class_docstr: Tests for the sample function
class_docstr_tok: ["Tests","for","the","sample","function"]
docstr: Test that a ValueError is raised if both an observable is provided and wires are specified
docstr_tok: ["Test","that","a","ValueError","is","raised","if","both","an","observable","is","provided","and","wires","are","specified"]
code: def test_providing_observable_and_wires(self):
      """Test that a ValueError is raised if both an observable is provided and wires are specified"""
      dev = qml.device("default.qubit", wires=2)
  
      @qml.qnode(dev)
      def circuit():
          qml.Hadamard(wires=0)
          return qml.sample(qml.PauliZ(0), wires=[0, 1])
  
      with pytest.raises(
          ValueError,
          match="Cannot specify the wires to sample if an observable is provided."
          " The wires to sample will be determined directly from the observable.",
      ):
          _ = circuit()
  
imports: import numpy
  import pytest
  import pennylane
  from pennylane.measurements import MeasurementShapeError, Sample, Shots
  from pennylane.operation import EigvalsUndefinedError, Operator
label_desc: Use image node_id 13 for calling the TestSample obj's underlying member method code with example usage: obj.test_providing_observable_and_wires() and returns: qml