1# Copyright 2020 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
15import pathlib
16
17import cirq
18from cirq.json_resolver_cache import _class_resolver_dictionary
19from cirq.testing.json import ModuleJsonTestSpec
20
21TestSpec = ModuleJsonTestSpec(
22    name="cirq",
23    packages=[cirq, cirq.work],
24    test_data_path=pathlib.Path(__file__).parent,
25    resolver_cache=_class_resolver_dictionary(),
26    not_yet_serializable=[
27        'Alignment',
28        'AnyIntegerPowerGateFamily',
29        'AnyUnitaryGateFamily',
30        'AxisAngleDecomposition',
31        'CircuitDag',
32        'CircuitDiagramInfo',
33        'CircuitDiagramInfoArgs',
34        'CircuitSampleJob',
35        'CliffordSimulatorStepResult',
36        'CliffordTrialResult',
37        'DensityMatrixSimulator',
38        'DensityMatrixSimulatorState',
39        'DensityMatrixStepResult',
40        'DensityMatrixTrialResult',
41        'ExpressionMap',
42        'GateFamily',
43        'Gateset',
44        'InsertStrategy',
45        'IonDevice',
46        'KakDecomposition',
47        'LinearCombinationOfGates',
48        'LinearCombinationOfOperations',
49        'Linspace',
50        'ListSweep',
51        'DiagonalGate',
52        'NeutralAtomDevice',
53        'ParallelGateFamily',
54        'PauliInteractionGate',
55        'PauliStringPhasor',
56        'PauliSum',
57        'PauliSumCollector',
58        'PauliSumExponential',
59        'PauliTransform',
60        'PeriodicValue',
61        'PointOptimizationSummary',
62        'Points',
63        'Product',
64        'QasmArgs',
65        'QasmOutput',
66        'QuantumState',
67        'QubitOrder',
68        'QubitPermutationGate',
69        'QuilFormatter',
70        'QuilOutput',
71        'SimulationTrialResult',
72        'SparseSimulatorStep',
73        'StateVectorMixin',
74        'TextDiagramDrawer',
75        'ThreeQubitDiagonalGate',
76        'Timestamp',
77        'TwoQubitDiagonalGate',
78        'UnitSweep',
79        'StateVectorSimulatorState',
80        'StateVectorTrialResult',
81        'ZerosSampler',
82        'Zip',
83    ],
84    should_not_be_serialized=[
85        # Heatmaps
86        'Heatmap',
87        'TwoQubitInteractionHeatmap',
88        # Intermediate states with work buffers and unknown external prng guts.
89        'ActOnArgs',
90        'ActOnArgsContainer',
91        'ActOnCliffordTableauArgs',
92        'ActOnDensityMatrixArgs',
93        'ActOnStabilizerCHFormArgs',
94        'ActOnStateVectorArgs',
95        'ApplyChannelArgs',
96        'ApplyMixtureArgs',
97        'ApplyUnitaryArgs',
98        'OperationTarget',
99        # Circuit optimizers are function-like. Only attributes
100        # are ignore_failures, tolerance, and other feature flags
101        'AlignLeft',
102        'AlignRight',
103        'ConvertToCzAndSingleGates',
104        'ConvertToIonGates',
105        'ConvertToNeutralAtomGates',
106        'DropEmptyMoments',
107        'DropNegligible',
108        'EjectPhasedPaulis',
109        'EjectZ',
110        'ExpandComposite',
111        'MEASUREMENT_KEY_SEPARATOR',
112        'MergeInteractions',
113        'MergeInteractionsToSqrtIswap',
114        'MergeSingleQubitGates',
115        'PointOptimizer',
116        'SynchronizeTerminalMeasurements',
117        # global objects
118        'CONTROL_TAG',
119        'PAULI_BASIS',
120        'PAULI_STATES',
121        # abstract, but not inspect.isabstract():
122        'Device',
123        'InterchangeableQubitsGate',
124        'Pauli',
125        'SingleQubitGate',
126        'ThreeQubitGate',
127        'TwoQubitGate',
128        'ABCMetaImplementAnyOneOf',
129        'GenericMetaImplementAnyOneOf',
130        'SimulatesAmplitudes',
131        'SimulatesExpectationValues',
132        'SimulatesFinalState',
133        'NamedTopology',
134        # protocols:
135        'SupportsActOn',
136        'SupportsActOnQubits',
137        'SupportsApplyChannel',
138        'SupportsApplyMixture',
139        'SupportsApproximateEquality',
140        'SupportsCircuitDiagramInfo',
141        'SupportsCommutes',
142        'SupportsConsistentApplyUnitary',
143        'SupportsDecompose',
144        'SupportsDecomposeWithQubits',
145        'SupportsEqualUpToGlobalPhase',
146        'SupportsExplicitHasUnitary',
147        'SupportsExplicitNumQubits',
148        'SupportsExplicitQidShape',
149        'SupportsJSON',
150        'SupportsKraus',
151        'SupportsMeasurementKey',
152        'SupportsMixture',
153        'SupportsParameterization',
154        'SupportsPauliExpansion',
155        'SupportsPhase',
156        'SupportsQasm',
157        'SupportsQasmWithArgs',
158        'SupportsQasmWithArgsAndQubits',
159        'SupportsTraceDistanceBound',
160        'SupportsUnitary',
161        # mypy types:
162        'CIRCUIT_LIKE',
163        'DURATION_LIKE',
164        'JsonResolver',
165        'NOISE_MODEL_LIKE',
166        'OP_TREE',
167        'PAULI_GATE_LIKE',
168        'PAULI_STRING_LIKE',
169        'ParamResolverOrSimilarType',
170        'PauliSumLike',
171        'QUANTUM_STATE_LIKE',
172        'QubitOrderOrList',
173        'RANDOM_STATE_OR_SEED_LIKE',
174        'STATE_VECTOR_LIKE',
175        'Sweepable',
176        'TParamKey',
177        'TParamVal',
178        'ParamDictType',
179        # utility:
180        'CliffordSimulator',
181        'Simulator',
182        'StabilizerSampler',
183        'Unique',
184        'DEFAULT_RESOLVERS',
185    ],
186    deprecated={
187        'ParallelGateOperation': 'v0.14',
188    },
189    tested_elsewhere=[
190        # SerializableByKey does not follow common serialization rules.
191        # It is tested separately in test_context_serialization.
192        'SerializableByKey',
193    ],
194)
195