Ejemplo n.º 1
0
    def _from_memoized_dict(cls, mm_dict, serial_memo):
        base_matrix = cls._decodemx(mm_dict['base_matrix'])
        parameter_array = cls._decodemx(mm_dict['parameter_array'])
        left_transform = cls._decodemx(mm_dict['left_transform'])
        right_transform = cls._decodemx(mm_dict['right_transform'])
        state_space = _StateSpace.from_nice_serialization(mm_dict['state_space'])

        return cls(base_matrix, parameter_array, mm_dict['parameter_to_base_indices_map'],
                   left_transform, right_transform, mm_dict['enforce_real'], mm_dict['evotype'], state_space)
Ejemplo n.º 2
0
 def _from_memoized_dict(cls, mm_dict, serial_memo):
     state_space = _StateSpace.from_nice_serialization(
         mm_dict['state_space'])
     effects = {
         lbl: serial_memo[subm_serial_id]
         for lbl, subm_serial_id in zip(mm_dict['effect_labels'],
                                        mm_dict['submembers'])
     }
     return cls(
         effects, mm_dict['evotype'],
         state_space)  # Note: __init__ call signature of derived classes
Ejemplo n.º 3
0
    def _from_nice_serialization(cls, state):
        state_space = _StateSpace.from_nice_serialization(state['state_space'])
        layer_rules = _LayerRules.from_nice_serialization(state['layer_rules'])
        basis = _Basis.from_nice_serialization(state['basis'])
        modelmembers = _MMGraph.load_modelmembers_from_serialization_dict(
            state['modelmembers'])
        simulator = _FSim.from_nice_serialization(state['simulator'])

        mdl = cls(state_space, layer_rules, basis, simulator, state['evotype'])

        root_dicts = {
            'prep_blks': mdl.prep_blks,
            'povm_blks': mdl.povm_blks,
            'operation_blks': mdl.operation_blks,
            'instrument_blks': mdl.instrument_blks,
            'factories': mdl.factories,
        }
        for mm_key, mm_dict in modelmembers.items():
            root_key, sub_key = mm_key.split('|')
            root_dicts[root_key][sub_key].update(
                mm_dict)  # Note: sub_keys should already be created
        return mdl
Ejemplo n.º 4
0
    def _from_memoized_dict(cls, mm_dict, serial_memo):
        state_space = _StateSpace.from_nice_serialization(
            mm_dict['state_space'])

        # Alternate __init__ because we already have members built:
        lbl_member_pairs = [
            (lbl, serial_memo[subm_serial_id]) for lbl, subm_serial_id in zip(
                mm_dict['member_labels'], mm_dict['submembers'])
        ]
        MT_member = next(
            filter(lambda pair: pair[1].index == len(lbl_member_pairs) - 1,
                   lbl_member_pairs))
        param_ops = MT_member.submembers(
        )  # the final (TP) member has all the param_ops as its submembers

        ret = TPInstrument.__new__(TPInstrument)
        ret.param_ops = param_ops
        ret._readonly = False
        _collections.OrderedDict.__init__(ret, lbl_member_pairs)
        _mm.ModelMember.__init__(ret, state_space, mm_dict['evotype'])
        ret._readonly = True
        return ret
Ejemplo n.º 5
0
 def _from_memoized_dict(cls, mm_dict, serial_memo):
     matrix = cls._decodemx(mm_dict['dense_matrix'])
     state_space = _StateSpace.from_nice_serialization(mm_dict['state_space'])
     return cls(matrix, mm_dict['include_off_diags_in_degen_2_blocks'],
                mm_dict['tp_constrained_and_unital'], mm_dict['evotype'], state_space)
Ejemplo n.º 6
0
 def _from_memoized_dict(cls, mm_dict, serial_memo):
     state_space = _StateSpace.from_nice_serialization(
         mm_dict['state_space'])
     members = [(lbl, serial_memo[subm_serial_id]) for lbl, subm_serial_id
                in zip(mm_dict['member_labels'], mm_dict['submembers'])]
     return cls(members, mm_dict['evotype'], state_space)
Ejemplo n.º 7
0
 def _from_memoized_dict(cls, mm_dict, serial_memo):
     state_space = _StateSpace.from_nice_serialization(mm_dict['state_space'])
     return cls(state_space, mm_dict['target_labels'], serial_memo[mm_dict['submembers'][0]])
Ejemplo n.º 8
0
 def _from_nice_serialization(cls, state):
     state_space = _StateSpace.from_nice_serialization(state['state_space'])
     return cls(state_space, state['use_cache'])