Transform dictionary from pairs of keys to dict -> dict -> float
519646
def curry_pair_dictionary(key_pair_dict, default_value=0.0):
    
    result = defaultdict(dict)
    for (a, b), value in key_pair_dict.items():
        result[a][b] = value
    return result
913145
def as_dict(self):
        """"""

        d = {}
        for key, value in self:
            d.setdefault(key, []).append(value)
        return d
51789
def to_dicts(recarray):
    """"""
    for rec in recarray:
        yield dict(zip(recarray.dtype.names, rec.tolist()))
881332
def __merge_values(self, from_dict, to_dict):
        
        for key, value in from_dict.iteritems():

            # Only if the key already exists
            if key in to_dict:

                # Make sure the values are the same datatype
                assert type(to_dict[key]) is type(from_dict[key]), 'Data type for {0} is incorrect: {1}, should be {2}'.format(key, type(from_dict[key]), type(to_dict[key]))

                # Recursively dive into the next dictionary
                if type(to_dict[key]) is dict:
                    to_dict[key] = self.__merge_values(from_dict[key], to_dict[key])

                # Replace value
                else:
                    to_dict[key] = from_dict[key]

        return to_dict
495792
def dict_assign(dict_, keys, vals):
    
    for key, val in zip(keys, vals):
        dict_[key] = val
609708
def _dict_compose(dict1, dict2):
    
    return {k: dict2.get(v) for k, v in dict1.items() if v in dict2}
1329231
def from_dict(cls, d):
        
        return cls(xc=d.get("xc"), x=d.get("x"), c=d.get("c"))
823728
def flip_iterable_dict(d: dict) -> dict:
    """"""

    value_keys = disjoint_union((cartesian_product((v, k))
                                 for k, v in d.items()))
    return dict(value_keys)
111263
def _convert(tup, dictlist):
    
    di = {}
    for a, b in tup:
        di.setdefault(a, []).append(b)
    for key, val in di.items():
        dictlist.append((key, val))
    return dictlist
198316
def _flatten_dicts(self, dicts):
        
        d = dict()
        list_of_dicts = [d.get() for d in dicts or []]
        return {k: v for d in list_of_dicts for k, v in d.items()}
364562
def combined_dict(*dicts):
  """"""
  return {k: v for d in dicts for k, v in d.items()}
776625
def dict_map(f, primitive, dic):
    """"""

    if primitive(dic):
        return f(dic)
    if isinstance(dic, Mapping):
        return {dict_map(f, primitive, key): dict_map(f, primitive, value)
                for key, value in dic.items()}
    if isinstance(dic, str):
        return dic
    if isinstance(dic, Sequence):
        return [dict_map(f, primitive, value) for value in dic]
    return dic
1014447
def flatten_multidict(multidict):
    """"""
    return dict([(key, value if len(value) > 1 else value[0])
                 for (key, value) in multidict.iterlists()])
236648
def getfloat(self, key, **kwargs):
        

        return self.get(key, cast_func=float, **kwargs)
150720
def from_dict(cls, d):
        """"""
        read = lambda cls: (lambda pair: (pair[0], cls.from_dict(pair[1])))
        return cls(
            variables=map(read(Variable), d.get('variables', {}).items()),
            properties=map(read(Property), d.get('properties', {}).items()),
            roles=map(read(Role), d.get('roles', {}).items()),
            predicates=map(read(Predicate), d.get('predicates', {}).items())
        )
1292914
def _to_key_val_pairs(defs):
    

    if isinstance(defs, STRING_TYPES):
        # Convert 'a' to [('a', None)], or 'a.b.c' to [('a', 'b.c')]
        return [defs.split('.', 1) if '.' in defs else (defs, None)]
    else:
        pairs = []

        # Convert collections of strings or lists as above; break dicts into component items
        pairs.extend(p for s in defs if isinstance(s, STRING_TYPES) for p in _to_key_val_pairs(s))
        pairs.extend(p for l in defs if isinstance(l, list) for p in _to_key_val_pairs(l))
        pairs.extend(p for d in defs if isinstance(d, dict) for p in iteritems(d))

        return pairs
598065
def fromkeys (cls, iterable, value=None):
        """"""
        d = cls()
        for k in iterable:
            dict.__setitem__(d, k.lower(), value)
        return d