Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement and enforce explicit re-export for cirq modules #6722

Merged
merged 25 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b726cff
Fixed issue #6717
ashiq-firoz Sep 8, 2024
ce9dd20
Fixed issue #6717
ashiq-firoz Sep 8, 2024
3a93702
Update __init__.py
ashiq-firoz Sep 8, 2024
ffa54ff
Fixed issue #6717
ashiq-firoz Sep 8, 2024
9161701
Fixed issue #6717
ashiq-firoz Sep 8, 2024
acfc2d1
Fixed issue #6717
ashiq-firoz Sep 8, 2024
eb26672
Fixed issue #6717
ashiq-firoz Sep 8, 2024
a72940c
Fixed issue #6717
ashiq-firoz Sep 8, 2024
c3613dc
Fixed issue #6717
ashiq-firoz Sep 8, 2024
d653c80
Fixed issue #6717
ashiq-firoz Sep 8, 2024
1328157
Fixed issue #6717
ashiq-firoz Sep 8, 2024
808a6db
Made changes as mentioned
ashiq-firoz Sep 10, 2024
ed39e49
Apply the no_implicit_reexport mypy rule for cirq modules only
pavoljuhas Sep 11, 2024
fe2b244
Import ModuleType directly from types
pavoljuhas Sep 11, 2024
34c9279
Clean obsolete workaround for a dead mypy bug
pavoljuhas Sep 11, 2024
445084a
Fix complaint about reexport of InsertStrategy from cirq.circuits.cir…
pavoljuhas Sep 11, 2024
827f34b
Fix complaint about reexport of PauliString
pavoljuhas Sep 11, 2024
fce7ca2
Fix complaint about reexport of SwapPowGate
pavoljuhas Sep 11, 2024
aeb546d
Format changed files
pavoljuhas Sep 11, 2024
c0db8ff
Do not re-export _register_resolver and _class_resolver_dictionary
pavoljuhas Sep 11, 2024
a7c21e1
Do not reexport `_compat` it is used internally in initialization
pavoljuhas Sep 11, 2024
61707d0
Revert modules that define exports with their `__all__` list
pavoljuhas Sep 11, 2024
d615c60
Clean spurious re-export
pavoljuhas Sep 11, 2024
93320e3
Do not re-export submodules already in the namespace
pavoljuhas Sep 11, 2024
7f98fd3
Address pylint on line-too-long
pavoljuhas Sep 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions cirq-aqt/cirq_aqt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

"""Types and methods related to the AQT ion trap device"""

from cirq_aqt._version import __version__
from cirq_aqt._version import __version__ as __version__
from cirq_aqt.aqt_sampler import AQTSampler as AQTSampler, AQTSamplerLocalSimulator as AQTSamplerLocalSimulator
from cirq_aqt.aqt_device import AQTSimulator as AQTSimulator


from cirq_aqt.aqt_sampler import AQTSampler, AQTSamplerLocalSimulator
from cirq_aqt.aqt_device import AQTSimulator
16 changes: 8 additions & 8 deletions cirq-core/cirq/circuits/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@

"""Circuit classes, mutators, and outputs."""

from cirq.circuits.text_diagram_drawer import TextDiagramDrawer
from cirq.circuits.text_diagram_drawer import TextDiagramDrawer as TextDiagramDrawer
from cirq.circuits.qasm_output import QasmOutput as QasmOutput

from cirq.circuits.qasm_output import QasmOutput
from cirq.circuits.circuit import AbstractCircuit as AbstractCircuit, Alignment as Alignment, Circuit as Circuit
from cirq.circuits.circuit_operation import CircuitOperation as CircuitOperation
from cirq.circuits.frozen_circuit import FrozenCircuit as FrozenCircuit
from cirq.circuits.insert_strategy import InsertStrategy as InsertStrategy

from cirq.circuits.circuit import AbstractCircuit, Alignment, Circuit
from cirq.circuits.circuit_operation import CircuitOperation
from cirq.circuits.frozen_circuit import FrozenCircuit
from cirq.circuits.insert_strategy import InsertStrategy
from cirq.circuits.moment import Moment as Moment

from cirq.circuits.moment import Moment
from cirq.circuits.optimization_pass import PointOptimizer as PointOptimizer, PointOptimizationSummary as PointOptimizationSummary

from cirq.circuits.optimization_pass import PointOptimizer, PointOptimizationSummary
13 changes: 7 additions & 6 deletions cirq-core/cirq/contrib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
this package.
"""

from cirq.contrib import acquaintance
from cirq.contrib import graph_device
from cirq.contrib import quirk
from cirq.contrib.qcircuit import circuit_to_latex_using_qcircuit
from cirq.contrib import json
from cirq.contrib.circuitdag import CircuitDag, Unique
from cirq.contrib import acquaintance as acquaintance
from cirq.contrib import graph_device as graph_device
from cirq.contrib import quirk as quirk
from cirq.contrib.qcircuit import circuit_to_latex_using_qcircuit as circuit_to_latex_using_qcircuit
from cirq.contrib import json as json
from cirq.contrib.circuitdag import CircuitDag as CircuitDag, Unique as Unique

52 changes: 27 additions & 25 deletions cirq-core/cirq/devices/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,47 @@

"""Device classes, qubits, and topologies, as well as noise models."""

from cirq.devices.device import Device, DeviceMetadata

from cirq.devices.grid_device_metadata import GridDeviceMetadata

from cirq.devices.grid_qubit import GridQid, GridQubit
from cirq.devices.device import Device as Device, DeviceMetadata as DeviceMetadata

from cirq.devices.line_qubit import LineQubit, LineQid
from cirq.devices.grid_device_metadata import GridDeviceMetadata as GridDeviceMetadata

from cirq.devices.unconstrained_device import UNCONSTRAINED_DEVICE
from cirq.devices.grid_qubit import GridQid as GridQid, GridQubit as GridQubit

from cirq.devices.noise_model import NO_NOISE, NOISE_MODEL_LIKE, NoiseModel, ConstantQubitNoiseModel
from cirq.devices.line_qubit import LineQubit as LineQubit, LineQid as LineQid

from cirq.devices.unconstrained_device import UNCONSTRAINED_DEVICE as UNCONSTRAINED_DEVICE

from cirq.devices.noise_model import NO_NOISE as NO_NOISE, NOISE_MODEL_LIKE as NOISE_MODEL_LIKE, NoiseModel as NoiseModel, ConstantQubitNoiseModel as ConstantQubitNoiseModel

from cirq.devices.named_topologies import (
NamedTopology,
draw_gridlike,
LineTopology,
TiltedSquareLattice,
get_placements,
is_valid_placement,
draw_placements,
NamedTopology as NamedTopology,
draw_gridlike as draw_gridlike,
LineTopology as LineTopology,
TiltedSquareLattice as TiltedSquareLattice,
get_placements as get_placements,
is_valid_placement as is_valid_placement,
draw_placements as draw_placements,
)

from cirq.devices.insertion_noise_model import InsertionNoiseModel
from cirq.devices.insertion_noise_model import InsertionNoiseModel as InsertionNoiseModel

from cirq.devices.thermal_noise_model import ThermalNoiseModel
from cirq.devices.thermal_noise_model import ThermalNoiseModel as ThermalNoiseModel

from cirq.devices.noise_properties import NoiseModelFromNoiseProperties, NoiseProperties
from cirq.devices.noise_properties import NoiseModelFromNoiseProperties as NoiseModelFromNoiseProperties, NoiseProperties as NoiseProperties

from cirq.devices.superconducting_qubits_noise_properties import (
SuperconductingQubitsNoiseProperties,
SuperconductingQubitsNoiseProperties as SuperconductingQubitsNoiseProperties,
)

from cirq.devices.noise_utils import (
OpIdentifier,
decay_constant_to_xeb_fidelity,
decay_constant_to_pauli_error,
pauli_error_to_decay_constant,
xeb_fidelity_to_decay_constant,
pauli_error_from_t1,
average_error,
decoherence_pauli_error,
OpIdentifier as OpIdentifier,
decay_constant_to_xeb_fidelity as decay_constant_to_xeb_fidelity,
decay_constant_to_pauli_error as decay_constant_to_pauli_error,
pauli_error_to_decay_constant as pauli_error_to_decay_constant,
xeb_fidelity_to_decay_constant as xeb_fidelity_to_decay_constant,
pauli_error_from_t1 as pauli_error_from_t1,
average_error as average_error,
decoherence_pauli_error as decoherence_pauli_error,
)
1 change: 1 addition & 0 deletions cirq-core/cirq/experiments/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Experiments and tools for characterizing quantum operations."""
from foo import bar as bar
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove as well as other debugging code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure I will work on that


from cirq.experiments.qubit_characterizations import (
RandomizedBenchMarkResult,
Expand Down
1 change: 1 addition & 0 deletions cirq-core/cirq/interop/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
# limitations under the License.
"""Methods for interoperating with other quantum software."""

from foo import bar as bar
from cirq.interop.quirk import quirk_json_to_circuit, quirk_url_to_circuit
142 changes: 71 additions & 71 deletions cirq-google/cirq_google/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,102 +15,102 @@
"""Classes for working with Google's Quantum Engine API."""

import sys
from cirq_google import api
from cirq_google import api as api

from cirq_google._version import __version__
from cirq_google._version import __version__ as __version__

from cirq_google.devices import (
GoogleNoiseProperties,
GridDevice,
NoiseModelFromGoogleNoiseProperties,
Sycamore,
Sycamore23,
GoogleNoiseProperties as GoogleNoiseProperties,
GridDevice as GridDevice,
NoiseModelFromGoogleNoiseProperties as NoiseModelFromGoogleNoiseProperties,
Sycamore as Sycamore,
Sycamore23 as Sycamore23,
)

from cirq_google.engine import (
Calibration,
CalibrationLayer,
CalibrationResult,
Engine,
EngineJob,
EngineProgram,
EngineProcessor,
EngineResult,
ProtoVersion,
ProcessorSampler,
ValidatingSampler,
get_engine,
get_engine_calibration,
get_engine_device,
get_engine_sampler,
noise_properties_from_calibration,
Calibration as Calibration,
CalibrationLayer as CalibrationLayer,
CalibrationResult as CalibrationResult,
Engine as Engine,
EngineJob as EngineJob,
EngineProgram as EngineProgram,
EngineProcessor as EngineProcessor,
EngineResult as EngineResult,
ProtoVersion as ProtoVersion,
ProcessorSampler as ProcessorSampler,
ValidatingSampler as ValidatingSampler,
get_engine as get_engine,
get_engine_calibration as get_engine_calibration,
get_engine_device as get_engine_device,
get_engine_sampler as get_engine_sampler,
noise_properties_from_calibration as noise_properties_from_calibration,
)

from cirq_google.line import (
AnnealSequenceSearchStrategy,
GreedySequenceSearchStrategy,
line_on_device,
LinePlacementStrategy,
AnnealSequenceSearchStrategy as AnnealSequenceSearchStrategy,
GreedySequenceSearchStrategy as GreedySequenceSearchStrategy,
line_on_device as line_on_device,
LinePlacementStrategy as LinePlacementStrategy,
)

from cirq_google.ops import (
CalibrationTag,
Coupler,
FSimGateFamily,
FSimViaModelTag,
InternalGate,
PhysicalZTag,
SYC,
SycamoreGate,
CalibrationTag as CalibrationTag,
Coupler as Coupler,
FSimGateFamily as FSimGateFamily,
FSimViaModelTag as FSimViaModelTag,
InternalGate as InternalGate,
PhysicalZTag as PhysicalZTag,
SYC as SYC,
SycamoreGate as SycamoreGate,
)

from cirq_google.transformers import (
known_2q_op_to_sycamore_operations,
two_qubit_matrix_to_sycamore_operations,
GoogleCZTargetGateset,
SycamoreTargetGateset,
known_2q_op_to_sycamore_operations as known_2q_op_to_sycamore_operations,
two_qubit_matrix_to_sycamore_operations as two_qubit_matrix_to_sycamore_operations,
GoogleCZTargetGateset as GoogleCZTargetGateset,
SycamoreTargetGateset as SycamoreTargetGateset,
)

from cirq_google.serialization import (
arg_from_proto,
CIRCUIT_SERIALIZER,
CircuitSerializer,
CircuitOpDeserializer,
CircuitOpSerializer,
Serializer,
arg_from_proto as arg_from_proto,
CIRCUIT_SERIALIZER as CIRCUIT_SERIALIZER,
CircuitSerializer as CircuitSerializer,
CircuitOpDeserializer as CircuitOpDeserializer,
CircuitOpSerializer as CircuitOpSerializer,
Serializer as Serializer,
)

from cirq_google.workflow import (
ExecutableSpec,
KeyValueExecutableSpec,
QuantumExecutable,
QuantumExecutableGroup,
BitstringsMeasurement,
SharedRuntimeInfo,
RuntimeInfo,
ExecutableResult,
ExecutableGroupResult,
ExecutableGroupResultFilesystemRecord,
QuantumRuntimeConfiguration,
execute,
QubitPlacer,
CouldNotPlaceError,
NaiveQubitPlacer,
RandomDevicePlacer,
HardcodedQubitPlacer,
ProcessorRecord,
EngineProcessorRecord,
SimulatedProcessorRecord,
SimulatedProcessorWithLocalDeviceRecord,
ExecutableSpec as ExecutableSpec,
KeyValueExecutableSpec as KeyValueExecutableSpec,
QuantumExecutable as QuantumExecutable,
QuantumExecutableGroup as QuantumExecutableGroup,
BitstringsMeasurement as BitstringsMeasurement,
SharedRuntimeInfo as SharedRuntimeInfo,
RuntimeInfo as RuntimeInfo,
ExecutableResult as ExecutableResult,
ExecutableGroupResult as ExecutableGroupResult,
ExecutableGroupResultFilesystemRecord as ExecutableGroupResultFilesystemRecord,
QuantumRuntimeConfiguration as QuantumRuntimeConfiguration,
execute as execute,
QubitPlacer as QubitPlacer,
CouldNotPlaceError as CouldNotPlaceError,
NaiveQubitPlacer as NaiveQubitPlacer,
RandomDevicePlacer as RandomDevicePlacer,
HardcodedQubitPlacer as HardcodedQubitPlacer,
ProcessorRecord as ProcessorRecord,
EngineProcessorRecord as EngineProcessorRecord,
SimulatedProcessorRecord as SimulatedProcessorRecord,
SimulatedProcessorWithLocalDeviceRecord as SimulatedProcessorWithLocalDeviceRecord,
)

from cirq_google import study

from cirq_google import experimental
from cirq_google import study as study

from cirq_google import experimental as experimental

# Register cirq_google's public classes for JSON serialization.
from cirq.protocols.json_serialization import _register_resolver
from cirq_google.json_resolver_cache import _class_resolver_dictionary
from cirq.protocols.json_serialization import _register_resolver as _register_resolver
from cirq_google.json_resolver_cache import _class_resolver_dictionary as _class_resolver_dictionary


_register_resolver(_class_resolver_dictionary)
2 changes: 1 addition & 1 deletion cirq-google/cirq_google/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# limitations under the License.
"""Helpers for converting to/from api data formats."""

from cirq_google.api import v2
from cirq_google.api import v2 as v2
20 changes: 10 additions & 10 deletions cirq-google/cirq_google/api/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
# limitations under the License.
"""Data format v1 for google api."""

from cirq_google.api.v1 import operations_pb2, params_pb2, program_pb2
from cirq_google.api.v1 import operations_pb2 as operations_pb2, params_pb2 as params_pb2, program_pb2 as program_pb2

from cirq_google.api.v1.params import sweep_from_proto, sweep_to_proto
from cirq_google.api.v1.params import sweep_from_proto as sweep_from_proto, sweep_to_proto as sweep_to_proto

from cirq_google.api.v1.programs import (
gate_to_proto,
is_native_xmon_gate,
is_native_xmon_op,
pack_results,
circuit_as_schedule_to_protos,
circuit_from_schedule_from_protos,
unpack_results,
xmon_op_from_proto,
gate_to_proto as gate_to_proto,
is_native_xmon_gate as is_native_xmon_gate,
is_native_xmon_op as is_native_xmon_op,
pack_results as pack_results,
circuit_as_schedule_to_protos as circuit_as_schedule_to_protos,
circuit_from_schedule_from_protos as circuit_from_schedule_from_protos,
unpack_results as unpack_results,
xmon_op_from_proto as xmon_op_from_proto,
)
27 changes: 14 additions & 13 deletions cirq-google/cirq_google/api/v2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,24 @@
# limitations under the License.
"""Data format v2 for google api."""

from cirq_google.api.v2 import device_pb2, metrics_pb2, program_pb2, result_pb2, run_context_pb2
from cirq_google.api.v2 import device_pb2 as device_pb2, metrics_pb2 as metrics_pb2, program_pb2 as program_pb2, result_pb2 as result_pb2, run_context_pb2 as run_context_pb2

from cirq_google.api.v2.program import (
grid_qubit_from_proto_id,
line_qubit_from_proto_id,
named_qubit_from_proto_id,
qubit_from_proto_id,
qubit_to_proto_id,
grid_qubit_from_proto_id as grid_qubit_from_proto_id,
line_qubit_from_proto_id as line_qubit_from_proto_id,
named_qubit_from_proto_id as named_qubit_from_proto_id,
qubit_from_proto_id as qubit_from_proto_id,
qubit_to_proto_id as qubit_to_proto_id,
)

from cirq_google.api.v2.results import (
MeasureInfo,
find_measurements,
pack_bits,
unpack_bits,
results_from_proto,
results_to_proto,
MeasureInfo as MeasureInfo,
find_measurements as find_measurements,
pack_bits as pack_bits,
unpack_bits as unpack_bits,
results_from_proto as results_from_proto,
results_to_proto as results_to_proto,
)

from cirq_google.api.v2.sweeps import run_context_to_proto, sweep_from_proto, sweep_to_proto
from cirq_google.api.v2.sweeps import run_context_to_proto as run_context_to_proto, sweep_from_proto as sweep_from_proto, sweep_to_proto as sweep_to_proto

Loading
Loading