class_docstr: Tests for ``group_observables`` function using QWC, commuting, and anticommuting partitioning.
class_docstr_tok: ["Tests","for","``","group_observables","``","function","using","QWC",",","commuting",",","and","anticommuting","partitioning","."]
code: def test_qwc_partitioning(self, observables, qwc_partitions_sol):
      qwc_partitions = group_observables(
          observables, grouping_type="qwc"
      )
  
      # assert the correct number of partitions:
      n_partitions = len(qwc_partitions_sol)
      assert len(qwc_partitions) == n_partitions
      # assert each partition is of the correct length:
      assert all(
          len(part) == len(part_sol)
          for part, part_sol in zip(qwc_partitions, qwc_partitions_sol)
      )
      # assert each partition contains the same Pauli terms as the solution partition:
      for i, partition in enumerate(qwc_partitions):
          for j, pauli in enumerate(partition):
              assert are_identical_pauli_words(
                  pauli, qwc_partitions_sol[i][j]
              )
  
imports: import pytest
  import numpy
  import pennylane
  from pennylane import Identity, PauliX, PauliY, PauliZ
  from pennylane.pauli import are_identical_pauli_words
  from pennylane.pauli.grouping.group_observables import PauliGroupingStrategy, group_observables
  from pennylane import numpy
label_desc: Use image node_id 1 for calling the TestGroupObservables obj's underlying member method code with example usage: obj.test_qwc_partitioning(observables, qwc_partitions_sol) without return types