class_docstr: Test the purity meausrement with qnodes and devices.
class_docstr_tok: ["Test","the","purity","meausrement","with","qnodes","and","devices","."]
docstr: Tests purity for a qnode on a noisy device with bit flips
docstr_tok: ["Tests","purity","for","a","qnode","on","a","noisy","device","with","bit","flips"]
code: def test_bit_flip_qnode_purity(
      self, device, wires, param, is_partial
  ):
      """Tests purity for a qnode on a noisy device with bit flips"""
  
      dev = qml.device(device, wires=2)
  
      @qml.qnode(dev)
      def circuit(p):
          qml.Hadamard(wires=0)
          qml.CNOT(wires=[0, 1])
          qml.BitFlip(p, wires=0)
          qml.BitFlip(p, wires=1)
          return qml.purity(wires=wires)
  
      purity = circuit(param)
      expected_purity = (
          0.5
          if is_partial
          else 4 * (0.5 - (1 - param) * param) ** 2
          + 4 * (1 - param) ** 2 * param**2
      )
      assert qml.math.allclose(purity, expected_purity)
  
imports: import pytest
  import numpy
  import pennylane
  from pennylane.measurements import PurityMP, Shots
label_desc: Use image node_id 2 for calling the TestPurityIntegration obj's underlying member method code with example usage: obj.test_bit_flip_qnode_purity(device, wires, param, is_partial) and returns: qml