def convert_ldicts_to_sdict(blocker_list): s = ShareDict() for blocker in blocker_list: for k, v in blocker.iteritems(): d = {} d[k] = v s.update_with_key(d, key=k) return s
def __init__(self, dask, name, n_chunk, slice_dim): if not isinstance(dask, ShareDict): s = ShareDict() s.update_with_key(dask, key=name) dask = s self.dask = dask self.name = name self.n_chunk = n_chunk self.slice_dim = slice_dim
def test_keys_items(): s = ShareDict() s.update_with_key(a, key='a') s.update_with_key(b, key='b') s.update_with_key(c, key='c') d = merge(a, b, c) for fn in [dict, set, len]: assert fn(s) == fn(d) for fn in [lambda x: x.values(), lambda x: x.keys(), lambda x: x.items()]: assert set(fn(s)) == set(fn(d))
def test_structure_2(): s = ShareDict() s.update_with_key(a, key='a') s.update_with_key(b, key='b') s.update_with_key(c, key='c') assert s.order == ['a', 'b', 'c'] s.update_with_key(b, key='b') assert s.order == ['a', 'c', 'b']
def test_structure_2(): s = ShareDict() s.update_with_key(a, key="a") s.update_with_key(b, key="b") s.update_with_key(c, key="c") assert s.order == ["a", "b", "c"] s.update_with_key(b, key="b") assert s.order == ["a", "c", "b"]
def test_update_with_sharedict(): s = ShareDict() s.update_with_key(a, key='a') s.update_with_key(b, key='b') s.update_with_key(c, key='c') d = {'z': 5} s2 = ShareDict() s2.update_with_key(a, key='a') s2.update_with_key(d, key='d') s.update(s2) assert s.dicts['a'] is s.dicts['a']
def test_update_with_sharedict(): s = ShareDict() s.update_with_key(a, key="a") s.update_with_key(b, key="b") s.update_with_key(c, key="c") d = {"z": 5} s2 = ShareDict() s2.update_with_key(a, key="a") s2.update_with_key(d, key="d") s.update(s2) assert s.dicts["a"] is s.dicts["a"]