Decode a dictionary, as from :meth:`to_dict`, into a Dmrs object.
509100
def from_dict(cls, d):
        
        def _node(obj):
            return Node(
                obj.get('nodeid'),
                Pred.surface_or_abstract(obj.get('predicate')),
                sortinfo=obj.get('sortinfo'),
                lnk=_lnk(obj.get('lnk')),
                surface=obj.get('surface'),
                base=obj.get('base'),
                carg=obj.get('carg')
            )
        def _link(obj):
            return Link(obj.get('from'), obj.get('to'),
                        obj.get('rargname'), obj.get('post'))
        def _lnk(o):
            return None if o is None else Lnk.charspan(o['from'], o['to'])
        return cls(
            nodes=[_node(n) for n in d.get('nodes', [])],
            links=[_link(l) for l in d.get('links', [])],
            lnk=_lnk(d.get('lnk')),
            surface=d.get('surface'),
            identifier=d.get('identifier')
        )
1006497
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'sentence' in _dict:
            args['sentence'] = _dict.get('sentence')
        if 'subject' in _dict:
            args['subject'] = SemanticRolesResultSubject._from_dict(
                _dict.get('subject'))
        if 'action' in _dict:
            args['action'] = SemanticRolesResultAction._from_dict(
                _dict.get('action'))
        if 'object' in _dict:
            args['object'] = SemanticRolesResultObject._from_dict(
                _dict.get('object'))
        return cls(**args)
870120
def serialize_to_dict(dictionary):
    ''''''
    retval = {}
    
    for k, v in dictionary.items():
        if isinstance(v, dict):
            retval[k] = serialize_to_dict(v)
        else:
            # This is when custom serialization happens
            if isinstance(v, np.ndarray):
                if v.dtype == 'float64':
                    # We don't support float64 on js side
                    v = v.astype('float32')

                retval[k] = encode_numpy(v)
            else:
                retval[k] = v
    
    return retval
1238199
def _perm_dict_from_pyxb(self, access_pyxb):
        """"""
        subj_dict = self._subj_dict_from_pyxb(access_pyxb)
        return self._perm_dict_from_subj_dict(subj_dict)
1177990
def _from_dict(cls, _dict):
        """"""
        args = {}
        xtra = _dict.copy()
        if 'intent' in _dict:
            args['intent'] = _dict.get('intent')
            del xtra['intent']
        else:
            raise ValueError(
                'Required property \'intent\' not present in RuntimeIntent JSON'
            )
        if 'confidence' in _dict:
            args['confidence'] = _dict.get('confidence')
            del xtra['confidence']
        else:
            raise ValueError(
                'Required property \'confidence\' not present in RuntimeIntent JSON'
            )
        args.update(xtra)
        return cls(**args)
729697
def item_to_mrc(code, val):
    
    if isinstance(val, basestring):
        return [val_to_mrc(code, val)]

    if isinstance(val, dict):
        val = [val]

    return dicts_to_mrc(code, val)
1294438
def to_dict(self, get_value=None):
        """"""
        self.trim()
        result = {}
        for key, value in iteritems(self.counters):
            if get_value is not None:
                value = getattr(value, get_value)
            r = result
            for _key in key[:-1]:
                r = r.setdefault(_key, {})
            r[key[-1]] = value
        return result
317531
def _opts_to_dict(*opts):
	''''''
	ret = {}
	for key, val in opts:
		if key[:2] == '--':
			key = key[2:]
		elif key[:1] == '-':
			key = key[1:]
		if val == '':
			val = True
		ret[key.replace('-','_')] = val
	return ret
182908
def fromdict(dict):
        
        key = hb_decode(dict['key'])
        check_fraction = dict['check_fraction']
        return Merkle(check_fraction, key)
672617
def from_old_dict(cls, d):
        
        # Strip the label to recover initial string (see trick used in as_dict to handle $ chars)
        labels_dict = {k.strip(): v for k, v in d['labels_dict'].items()}
        projections = {}
        structure = None
        if 'projections' in d and len(d['projections']) != 0:
            structure = Structure.from_dict(d['structure'])
            projections = {}
            for spin in d['projections']:
                dd = []
                for i in range(len(d['projections'][spin])):
                    ddd = []
                    for j in range(len(d['projections'][spin][i])):
                        dddd = []
                        for k in range(len(d['projections'][spin][i][j])):
                            ddddd = []
                            orb = Orbital(k).name
                            for l in range(len(d['projections'][spin][i][j][
                                                   orb])):
                                ddddd.append(d['projections'][spin][i][j][
                                                 orb][l])
                            dddd.append(np.array(ddddd))
                        ddd.append(np.array(dddd))
                    dd.append(np.array(ddd))
                projections[Spin(int(spin))] = np.array(dd)

        return BandStructureSymmLine(
            d['kpoints'], {Spin(int(k)): d['bands'][k]
                           for k in d['bands']},
            Lattice(d['lattice_rec']['matrix']), d['efermi'],
            labels_dict, structure=structure, projections=projections)
1132911
def from_dict(d):
        
        kraus_ops = [KrausModel.unpack_kraus_matrix(k) for k in d['kraus_ops']]
        return KrausModel(d['gate'], d['params'], d['targets'], kraus_ops, d['fidelity'])
1321010
def decode_dict_keys(d, coding="utf-8"):
    """"""
    assert compat.PY2
    res = {}
    for k, v in d.items():  #
        if type(k) is str:
            k = k.decode(coding)
        if type(v) is dict:
            v = decode_dict_keys(v, coding)
        res[k] = v
    return res
764894
def recursive_dict_to_dict(rdict):
    
    d = {}
    for (k, v) in rdict.items():
        if isinstance(v, defaultdict):
            d[k] = recursive_dict_to_dict(v)
        else:
            d[k] = v
    return d
547301
def decode_dict(data):
    
    if six.PY3:
        return data
    rv = {}
    for key, value in iteritems(data):
        if isinstance(key, text_type):
            key = key.encode('utf-8')

        if isinstance(value, text_type):
            value = value.encode('utf-8')
        elif isinstance(value, list):
            value = _decode_list(value)
        # no need to recurse into dict, json library will do that
        rv[key] = value
    return rv
121133
def from_dict(cls, d):
        """"""
        warnings.warn(
            'from_dict is deprecated and will be removed in v1.0!',
            stacklevel=2)
        d = d or {}
        return cls(**d)
611661
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'models' in _dict:
            args['models'] = [
                Model._from_dict(x) for x in (_dict.get('models'))
            ]
        return cls(**args)
563396
def to_dict(self):
        
        return dict(
            addr=self.addr,
            protocol=self.protocol,
            weight=self.weight,
            last_checked=self.last_checked)