Skip to content

Commit ccf35e6

Browse files
authored
Fix ci-daily run on windows-2022 (#8082)
Problem: The `atol` used in a test of `sub_state_vector` cannot simulate low precision when the largest eigenvalue equals 1. Solution: Test with `imperfect_state` with a small artificial errors.
1 parent 7228447 commit ccf35e6

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

cirq-core/cirq/linalg/transformations_test.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -390,25 +390,28 @@ def test_sub_state_vector() -> None:
390390
)
391391

392392
# Reject factoring for very tight tolerance.
393+
imperfect_state = state * np.random.normal(1.0, 1e-6, state.shape)
393394
assert (
394-
cirq.sub_state_vector(state, [0, 1], default=_DEFAULT_ARRAY, atol=1e-16) is _DEFAULT_ARRAY
395+
cirq.sub_state_vector(imperfect_state, [0, 1], default=_DEFAULT_ARRAY, atol=1e-16)
396+
is _DEFAULT_ARRAY
395397
)
396398
assert (
397-
cirq.sub_state_vector(state, [2, 3, 4], default=_DEFAULT_ARRAY, atol=1e-16)
399+
cirq.sub_state_vector(imperfect_state, [2, 3, 4], default=_DEFAULT_ARRAY, atol=1e-16)
398400
is _DEFAULT_ARRAY
399401
)
400402
assert (
401-
cirq.sub_state_vector(state, [5, 6, 7, 8], default=_DEFAULT_ARRAY, atol=1e-16)
403+
cirq.sub_state_vector(imperfect_state, [5, 6, 7, 8], default=_DEFAULT_ARRAY, atol=1e-16)
402404
is _DEFAULT_ARRAY
403405
)
404406

405407
# Ensure None can be passed as the `default` argument
406-
assert cirq.sub_state_vector(state, [0, 1], default=None, atol=1e-16) is None
408+
assert cirq.sub_state_vector(imperfect_state, [0, 1], default=None, atol=1e-16) is None
407409

408410
# Permit invalid factoring for loose tolerance.
409411
for q1 in range(9):
410412
assert (
411-
cirq.sub_state_vector(state, [q1], default=_DEFAULT_ARRAY, atol=1) is not _DEFAULT_ARRAY
413+
cirq.sub_state_vector(imperfect_state, [q1], default=_DEFAULT_ARRAY, atol=1)
414+
is not _DEFAULT_ARRAY
412415
)
413416

414417

0 commit comments

Comments
 (0)