示例#1
0
    def wrap(cls):
        cls = dataclasses.dataclass(cls,
                                    init=init,
                                    repr=repr,
                                    eq=eq,
                                    order=order,
                                    unsafe_hash=unsafe_hash,
                                    frozen=frozen)

        cls._json_dict_ = lambda obj: cirq.obj_to_dict_helper(
            obj, [f.name for f in dataclasses.fields(cls)],
            namespace=namespace)

        if registry is not None:
            if namespace is not None:
                prefix = '{}.'.format(namespace)
            else:
                prefix = ''
            registry.register(prefix + cls.__name__, cls)

        return cls
示例#2
0
 def _json_dict_(self) -> Dict[str, Any]:
     return cirq.obj_to_dict_helper(self, ['phi'])
示例#3
0
 def _json_dict_(self) -> Dict[str, Any]:
     return cirq.obj_to_dict_helper(self,
                                    ['calibration_type', 'program', 'args'])
示例#4
0
 def _json_dict_(self):
     return cirq.obj_to_dict_helper(
         self, ['hold_time', 'coupling_mhz', 'rise_time', 'padding_time'])
示例#5
0
 def _json_dict_(self):
     return cirq.obj_to_dict_helper(self, attribute_names=[])
示例#6
0
 def _json_dict_(self):
     return cirq.obj_to_dict_helper(self, [])