def test_pstring_collection_empty(): pauli_collection = PauliStringCollection() assert pauli_collection.elements == [] assert pauli_collection.elements_by_weight == {} assert pauli_collection.min_weight() == 0 assert pauli_collection.support() == set() assert len(pauli_collection) == 0
def test_pstringcollection(): x = PauliString(spec="X") iz = PauliString(spec="IZ") xz = PauliString(spec="XZ") xzixx = PauliString(spec="XZIXX") pauli_collection = PauliStringCollection(x, iz, xz, xzixx) assert pauli_collection.elements == [x, iz, xz, xzixx] assert pauli_collection.elements_by_weight == { 1: Counter((x, iz)), 2: Counter((xz,)), 4: Counter((xzixx,)), } assert pauli_collection.min_weight() == 1 assert pauli_collection.max_weight() == 4 assert pauli_collection.support() == {0, 1, 3, 4} assert len(pauli_collection) == 4