Skip to content

Commit c90ec8e

Browse files
address comments
1 parent 53aaff5 commit c90ec8e

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

cirq-core/cirq/protocols/json_serialization_test.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from typing import Dict, List, Optional, Tuple, Type
2525
from unittest import mock
2626

27+
import attrs
2728
import networkx as nx
2829
import numpy as np
2930
import pandas as pd
@@ -790,3 +791,15 @@ def test_datetime():
790791
assert re_pst_dt == pst_dt
791792
assert re_pst_dt == utc_dt
792793
assert re_pst_dt == re_naive_dt
794+
795+
796+
@attrs.frozen
797+
class _TestAttrsClas:
798+
name: str
799+
x: int
800+
801+
802+
def test_attrs_json_dict():
803+
obj = _TestAttrsClas('test', x=123)
804+
js = json_serialization.attrs_json_dict(obj)
805+
assert js == {'name': 'test', 'x': 123}

cirq-core/cirq/value/condition.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ class BitMaskKeyCondition(Condition):
151151
- BitMaskKeyCondition.create_equal_mask('a', 13) -> (a & 13) == 13
152152
- BitMaskKeyCondition.create_not_equal_mask('a', 13) -> (a & 13) != 13
153153
154+
The bits in the bitmask have the same order as the qubits passed to `cirq.measure(...)`. That's the
155+
most significant bit corresponds to the the first (left most) qubit.
156+
154157
Attributes:
155158
- key: Measurement key.
156159
- index: integer index (same as KeyCondition.index).
@@ -179,6 +182,7 @@ def keys(self):
179182
def create_equal_mask(
180183
key: 'cirq.MeasurementKey', bitmask: int, *, index: int = -1
181184
) -> 'BitMaskKeyCondition':
185+
"""Creates a condition that evaluates (meas & bitmask) == bitmask."""
182186
return BitMaskKeyCondition(
183187
key, index, target_value=bitmask, equal_target=True, bitmask=bitmask
184188
)
@@ -187,6 +191,7 @@ def create_equal_mask(
187191
def create_not_equal_mask(
188192
key: 'cirq.MeasurementKey', bitmask: int, *, index: int = -1
189193
) -> 'BitMaskKeyCondition':
194+
"""Creates a condition that evaluates (meas & bitmask) != bitmask."""
190195
return BitMaskKeyCondition(
191196
key, index, target_value=bitmask, equal_target=False, bitmask=bitmask
192197
)

0 commit comments

Comments
 (0)