Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
daxfohl committed Mar 3, 2025
1 parent 777764a commit 25c8ab0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
7 changes: 4 additions & 3 deletions cirq-core/cirq/devices/grid_qubit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,14 +397,14 @@ def test_complex():
def test_numpy_index(dtype):
np5, np6, np3 = [dtype(i) for i in [5, 6, 3]]
q = cirq.GridQubit(np5, np6)
hash(q) # doesn't throw
assert hash(q) == hash(cirq.GridQubit(5, 6))
assert q.row == 5
assert q.col == 6
assert q.dimension == 2
assert isinstance(q.dimension, int)

q = cirq.GridQid(np5, np6, dimension=np3)
hash(q) # doesn't throw
assert hash(q) == hash(cirq.GridQid(5, 6, dimension=3))
assert q.row == 5
assert q.col == 6
assert q.dimension == 3
Expand All @@ -413,8 +413,9 @@ def test_numpy_index(dtype):

@pytest.mark.parametrize('dtype', (float, np.float64))
def test_non_integer_index(dtype):
# Not supported type-wise, but is used in practice, so behavior needs to be preserved.
q = cirq.GridQubit(dtype(5.5), dtype(6.5))
hash(q) # doesn't throw
assert hash(q) == hash(cirq.GridQubit(5.5, 6.5))
assert q.row == 5.5
assert q.col == 6.5
assert isinstance(q.row, dtype)
Expand Down
3 changes: 1 addition & 2 deletions cirq-core/cirq/devices/line_qubit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,20 +293,19 @@ def test_numpy_index(dtype):
q = cirq.LineQubit(np5)
assert hash(q) == 5
assert q.x == 5
assert q.x == dtype(5)
assert q.dimension == 2
assert isinstance(q.dimension, int)

q = cirq.LineQid(np5, dtype(3))
hash(q) # doesn't throw
assert q.x == 5
assert q.x == dtype(5)
assert q.dimension == 3
assert isinstance(q.dimension, int)


@pytest.mark.parametrize('dtype', (float, np.float64))
def test_non_integer_index(dtype):
# Not supported type-wise, but is used in practice, so behavior needs to be preserved.
q = cirq.LineQubit(dtype(5.5))
assert q.x == 5.5
assert q.x == dtype(5.5)
Expand Down

0 comments on commit 25c8ab0

Please sign in to comment.