class_docstr: Tests that sampling is correctly implemented.
class_docstr_tok: ["Tests","that","sampling","is","correctly","implemented","."]
docstr: Test that the sample function outputs samples of the right size
docstr_tok: ["Test","that","the","sample","function","outputs","samples","of","the","right","size"]
code: def test_sample_shape_and_dtype(
      self, gaussian_device_2_wires, observable, n_sample
  ):
      """Test that the sample function outputs samples of the right size"""
  
      gaussian_device_2_wires.shots = n_sample
      sample = gaussian_device_2_wires.sample(
          observable, Wires([0]), []
      )
  
      assert np.array_equal(sample.shape, (n_sample,))
      assert sample.dtype == np.dtype("float")
  
imports: import numpy
  import numpy.random
  import pytest
  from scipy.linalg import block_diag
  from scipy.special import factorial
  import pennylane
  from pennylane import DeviceError
  from pennylane.devices.default_gaussian import fock_prob, rotation, squeezing, quadratic_phase, beamsplitter, two_mode_squeezing, controlled_addition, controlled_phase, vacuum_state, coherent_state, squeezed_state, displaced_squeezed_state, thermal_state
  from pennylane.wires import Wires
label_desc: Use image node_id 4 for calling the TestSample obj's underlying member method code with example usage: obj.test_sample_shape_and_dtype(gaussian_device_2_wires, observable, n_sample) without return types