class_docstr: Tests that the template defines the correct decomposition.
class_docstr_tok: ["Tests","that","the","template","defines","the","correct","decomposition","."]
docstr: Test the ratio of imprimitive gates.
docstr_tok: ["Test","the","ratio","of","imprimitive","gates","."]
code: def test_ratio_imprim(self, ratio):
      """Test the ratio of imprimitive gates."""
      n_rots = 500
      weights = np.random.random(size=(1, n_rots))
  
      op = qml.RandomLayers(weights, wires=range(2), ratio_imprim=ratio)
      queue = op.decomposition()
  
      gate_names = [gate.name for gate in queue]
      ratio_impr = gate_names.count("CNOT") / len(gate_names)
      assert np.isclose(ratio_impr, ratio, atol=0.05)
  
imports: import pytest
  import numpy
  import pennylane
  from pennylane import numpy
label_desc: Use image node_id 3 for calling the TestDecomposition obj's underlying member method code with example usage: obj.test_ratio_imprim(ratio) without return types