From c2280e5727fe5ccf9d8398955befe3bc6f581dc4 Mon Sep 17 00:00:00 2001 From: Cheng Xing Date: Tue, 14 Jun 2022 01:37:45 +0000 Subject: [PATCH] cirq_google GridDevice: set JSON namespace to cirq.google --- cirq-google/cirq_google/devices/grid_device.py | 4 ++++ cirq-google/cirq_google/json_resolver_cache.py | 2 +- .../{GridDevice.json => cirq.google.GridDevice.json} | 2 +- .../{GridDevice.repr => cirq.google.GridDevice.repr} | 0 cirq-google/cirq_google/json_test_data/spec.py | 1 + 5 files changed, 7 insertions(+), 2 deletions(-) rename cirq-google/cirq_google/json_test_data/{GridDevice.json => cirq.google.GridDevice.json} (99%) rename cirq-google/cirq_google/json_test_data/{GridDevice.repr => cirq.google.GridDevice.repr} (100%) diff --git a/cirq-google/cirq_google/devices/grid_device.py b/cirq-google/cirq_google/devices/grid_device.py index 58c04cf9771..5f34882f6fa 100644 --- a/cirq-google/cirq_google/devices/grid_device.py +++ b/cirq-google/cirq_google/devices/grid_device.py @@ -369,6 +369,10 @@ def _repr_pretty_(self, p: Any, cycle: bool) -> None: def __repr__(self) -> str: return f'cirq_google.GridDevice({repr(self._metadata)})' + @classmethod + def _json_namespace_(cls) -> str: + return 'cirq.google' + def _json_dict_(self): return {'metadata': self._metadata} diff --git a/cirq-google/cirq_google/json_resolver_cache.py b/cirq-google/cirq_google/json_resolver_cache.py index 6cb6ea86b6f..1cfb7f5bfdb 100644 --- a/cirq-google/cirq_google/json_resolver_cache.py +++ b/cirq-google/cirq_google/json_resolver_cache.py @@ -33,7 +33,6 @@ def _class_resolver_dictionary() -> Dict[str, ObjectFactory]: 'GoogleNoiseProperties': cirq_google.GoogleNoiseProperties, 'SycamoreGate': cirq_google.SycamoreGate, 'GateTabulation': cirq_google.GateTabulation, - 'GridDevice': cirq_google.GridDevice, 'PhysicalZTag': cirq_google.PhysicalZTag, 'FSimGateFamily': cirq_google.FSimGateFamily, 'FloquetPhasedFSimCalibrationOptions': cirq_google.FloquetPhasedFSimCalibrationOptions, @@ -67,4 +66,5 @@ def _class_resolver_dictionary() -> Dict[str, ObjectFactory]: 'cirq.google.HardcodedQubitPlacer': cirq_google.HardcodedQubitPlacer, # pylint: enable=line-too-long 'cirq.google.EngineResult': cirq_google.EngineResult, + 'cirq.google.GridDevice': cirq_google.GridDevice, } diff --git a/cirq-google/cirq_google/json_test_data/GridDevice.json b/cirq-google/cirq_google/json_test_data/cirq.google.GridDevice.json similarity index 99% rename from cirq-google/cirq_google/json_test_data/GridDevice.json rename to cirq-google/cirq_google/json_test_data/cirq.google.GridDevice.json index 255fa94ee35..65747eab1e6 100644 --- a/cirq-google/cirq_google/json_test_data/GridDevice.json +++ b/cirq-google/cirq_google/json_test_data/cirq.google.GridDevice.json @@ -1,5 +1,5 @@ { - "cirq_type": "GridDevice", + "cirq_type": "cirq.google.GridDevice", "metadata": { "cirq_type": "GridDeviceMetadata", "qubit_pairs": [ diff --git a/cirq-google/cirq_google/json_test_data/GridDevice.repr b/cirq-google/cirq_google/json_test_data/cirq.google.GridDevice.repr similarity index 100% rename from cirq-google/cirq_google/json_test_data/GridDevice.repr rename to cirq-google/cirq_google/json_test_data/cirq.google.GridDevice.repr diff --git a/cirq-google/cirq_google/json_test_data/spec.py b/cirq-google/cirq_google/json_test_data/spec.py index 5ae602c1cdc..8db73a14776 100644 --- a/cirq-google/cirq_google/json_test_data/spec.py +++ b/cirq-google/cirq_google/json_test_data/spec.py @@ -77,6 +77,7 @@ 'SimulatedProcessorRecord', 'SimulatedProcessorWithLocalDeviceRecord', 'EngineResult', + 'GridDevice', ] }, resolver_cache=_class_resolver_dictionary(),