How to use the bidict.compat.iterkeys function in bidict

To help you get started, we’ve selected a few bidict examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jab / bidict / tests / test_hypothesis.py View on Github external
def test_bijectivity(bi_cls, init_items):
    """b[k] == v  <==>  b.inv[v] == k"""
    some_bidict = bi_cls(init_items)
    ordered = isinstance(some_bidict, OrderedBidictBase)
    collection = list if ordered else set
    keys = collection(iterkeys(some_bidict))
    vals = collection(itervalues(some_bidict))
    fwd_by_keys = collection(some_bidict[k] for k in iterkeys(some_bidict))
    inv_by_vals = collection(some_bidict.inv[v] for v in itervalues(some_bidict))
    assert keys == inv_by_vals
    assert vals == fwd_by_keys
    inv = some_bidict.inv
    inv_keys = collection(iterkeys(inv))
    inv_vals = collection(itervalues(inv))
    inv_fwd_by_keys = collection(inv[k] for k in iterkeys(inv))
    inv_inv_by_vals = collection(inv.inv[v] for v in itervalues(inv))
    assert inv_keys == inv_inv_by_vals
    assert inv_vals == inv_fwd_by_keys
github jab / bidict / tests / test_hypothesis.py View on Github external
def test_bijectivity(bi_cls, init_items):
    """b[k] == v  <==>  b.inv[v] == k"""
    some_bidict = bi_cls(init_items)
    ordered = isinstance(some_bidict, OrderedBidictBase)
    collection = list if ordered else set
    keys = collection(iterkeys(some_bidict))
    vals = collection(itervalues(some_bidict))
    fwd_by_keys = collection(some_bidict[k] for k in iterkeys(some_bidict))
    inv_by_vals = collection(some_bidict.inv[v] for v in itervalues(some_bidict))
    assert keys == inv_by_vals
    assert vals == fwd_by_keys
    inv = some_bidict.inv
    inv_keys = collection(iterkeys(inv))
    inv_vals = collection(itervalues(inv))
    inv_fwd_by_keys = collection(inv[k] for k in iterkeys(inv))
    inv_inv_by_vals = collection(inv.inv[v] for v in itervalues(inv))
    assert inv_keys == inv_inv_by_vals
    assert inv_vals == inv_fwd_by_keys
github jab / bidict / tests / test_hypothesis.py View on Github external
def test_bijectivity(bi_cls, init_items):
    """b[k] == v  <==>  b.inv[v] == k"""
    some_bidict = bi_cls(init_items)
    ordered = isinstance(some_bidict, OrderedBidictBase)
    collection = list if ordered else set
    keys = collection(iterkeys(some_bidict))
    vals = collection(itervalues(some_bidict))
    fwd_by_keys = collection(some_bidict[k] for k in iterkeys(some_bidict))
    inv_by_vals = collection(some_bidict.inv[v] for v in itervalues(some_bidict))
    assert keys == inv_by_vals
    assert vals == fwd_by_keys
    inv = some_bidict.inv
    inv_keys = collection(iterkeys(inv))
    inv_vals = collection(itervalues(inv))
    inv_fwd_by_keys = collection(inv[k] for k in iterkeys(inv))
    inv_inv_by_vals = collection(inv.inv[v] for v in itervalues(inv))
    assert inv_keys == inv_inv_by_vals
    assert inv_vals == inv_fwd_by_keys
github jab / bidict / tests / test_hypothesis.py View on Github external
def test_orderedbidict_reversed(ob_cls, init_items):
    """:meth:`bidict.OrderedBidictBase.__reversed__` should yield all the keys
    in an ordered bidict in the reverse-order they were inserted.
    """
    some_bidict = ob_cls(init_items)
    key_seqs = (some_bidict, list(iterkeys(some_bidict)), [KEY(pair) for pair in init_items])
    key_seqs_rev = (reversed(i) for i in key_seqs)
    assert all(i == j == k for (i, j, k) in izip(*key_seqs_rev))
github jab / bidict / tests / test_hypothesis.py View on Github external
def test_bidict_iter(bi_cls, init_items):
    """:meth:`bidict.BidictBase.__iter__` should yield all the keys in a bidict."""
    some_bidict = bi_cls(init_items)
    assert set(some_bidict) == set(iterkeys(some_bidict)) == set(KEY(pair) for pair in init_items)
github jab / bidict / tests / test_hypothesis.py View on Github external
def test_orderedbidict_iter(ob_cls, init_items):
    """:meth:`bidict.OrderedBidictBase.__iter__` should yield all the keys
    in an ordered bidict in the order they were inserted.
    """
    some_bidict = ob_cls(init_items)
    key_iters = (some_bidict, iterkeys(some_bidict), (KEY(pair) for pair in init_items))
    assert all(i == j == k for (i, j, k) in izip(*key_iters))
github jab / bidict / tests / test_hypothesis.py View on Github external
def test_bijectivity(bi_cls, init_items):
    """b[k] == v  <==>  b.inv[v] == k"""
    some_bidict = bi_cls(init_items)
    ordered = isinstance(some_bidict, OrderedBidictBase)
    collection = list if ordered else set
    keys = collection(iterkeys(some_bidict))
    vals = collection(itervalues(some_bidict))
    fwd_by_keys = collection(some_bidict[k] for k in iterkeys(some_bidict))
    inv_by_vals = collection(some_bidict.inv[v] for v in itervalues(some_bidict))
    assert keys == inv_by_vals
    assert vals == fwd_by_keys
    inv = some_bidict.inv
    inv_keys = collection(iterkeys(inv))
    inv_vals = collection(itervalues(inv))
    inv_fwd_by_keys = collection(inv[k] for k in iterkeys(inv))
    inv_inv_by_vals = collection(inv.inv[v] for v in itervalues(inv))
    assert inv_keys == inv_inv_by_vals
    assert inv_vals == inv_fwd_by_keys