class_docstr: Tests for the broadcast_expand transform
class_docstr_tok: ["Tests","for","the","broadcast_expand","transform"]
docstr: Test that the expansion works as expected.
docstr_tok: ["Test","that","the","expansion","works","as","expected","."]
code: def test_expansion(self, params, size, obs, exp_fn):
      """Test that the expansion works as expected."""
      tape = make_tape(*params, obs)
      assert tape.batch_size == size
  
      tapes, fn = qml.transforms.broadcast_expand(tape)
      assert len(tapes) == size
      assert all(_tape.batch_size is None for _tape in tapes)
  
      result = fn(qml.execute(tapes, dev, None))
      expected = exp_fn(*params)
  
      if len(tape.measurements) > 1 and size == 1:
          expected = expected.T
  
      assert qml.math.allclose(result, expected)
  
file_path: pennylane/tests/transforms/test_broadcast_expand.py
imports: import pytest
  import numpy
  import pennylane
  from pennylane import numpy
label_desc: Use image node_id 1 for calling the TestBroadcastExpand obj's underlying member method code with example usage: obj.test_expansion(params, size, obs, exp_fn) without return types