class_docstr: Test that broadcasting works as expected for the reduced_dm functions
class_docstr_tok: ["Test","that","broadcasting","works","as","expected","for","the","reduced_dm","functions"]
docstr: Test that broadcasting works for density matrices and full wires
docstr_tok: ["Test","that","broadcasting","works","for","density","matrices","and","full","wires"]
code: def test_reduced_dm_with_matrix_full_wires(self, wires, array_func):
      """Test that broadcasting works for density matrices and full wires"""
      density_matrix = array_func(
          [dm[0] for dm in density_matrices[:4]]
      )
  
      if wires == [0, 1]:
          expected_density_matrices = density_matrix
      else:
          expected_density_matrices = array_func(
              [
                  permute_two_qubit_dm(dm[0])
                  for dm in density_matrices[:4]
              ]
          )
  
      density_matrix = fn.reduce_dm(density_matrix, indices=wires)
      assert np.allclose(density_matrix, expected_density_matrices)
  
imports: import numpy
  import pytest
  from pennylane import numpy
  from pennylane import math
label_desc: Use image node_id 4 for calling the TestDensityMatrixBroadcasting obj's underlying member method code with example usage: obj.test_reduced_dm_with_matrix_full_wires(wires, array_func) without return types