1# Copyright 2018 The Cirq Developers
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15from itertools import product, combinations
16
17import pytest
18
19import cirq
20import cirq.contrib.acquaintance as cca
21
22
23@pytest.mark.parametrize('n_qubits, acquaintance_size', product(range(2, 6), range(2, 5)))
24def test_get_logical_acquaintance_opportunities(n_qubits, acquaintance_size):
25    qubits = cirq.LineQubit.range(n_qubits)
26    acquaintance_strategy = cca.complete_acquaintance_strategy(qubits, acquaintance_size)
27    initial_mapping = {q: i for i, q in enumerate(qubits)}
28    opps = cca.get_logical_acquaintance_opportunities(acquaintance_strategy, initial_mapping)
29    assert opps == set(frozenset(s) for s in combinations(range(n_qubits), acquaintance_size))
30