Ejemplo n.º 1
0
 def __init__(self, key, item):
     if key is None:
         self.key = self._default_hashkey
     elif not callable(key):
         self.key = getter(key)
     else:
         self.key = key
     self.item = item
Ejemplo n.º 2
0
def rowfunc(t):
    """ Rowfunc provides a function that can be mapped onto a sequence.

    >>> accounts = symbol('accounts', 'var * {name: string, amount: int}')
    >>> f = rowfunc(accounts['amount'])

    >>> row = ('Alice', 100)
    >>> f(row)
    100

    See Also:
        compute<Rowwise, Sequence>
    """
    from toolz.itertoolz import getter
    indices = [t._child.fields.index(col) for col in t.fields]
    return getter(indices)
Ejemplo n.º 3
0
def rowfunc(t):
    """ Rowfunc provides a function that can be mapped onto a sequence.

    >>> accounts = symbol('accounts', 'var * {name: string, amount: int}')
    >>> f = rowfunc(accounts['amount'])

    >>> row = ('Alice', 100)
    >>> f(row)
    100

    See Also:
        compute<Rowwise, Sequence>
    """
    from toolz.itertoolz import getter
    indices = [t._child.fields.index(col) for col in t.fields]
    return getter(indices)
Ejemplo n.º 4
0
def test_getter():
    assert getter(0)('Alice') == 'A'
    assert getter([0])('Alice') == ('A',)
    assert getter([])('Alice') == ()
Ejemplo n.º 5
0
def test_getter():
    assert getter(0)('Alice') == 'A'
    assert getter([0])('Alice') == ('A', )
    assert getter([])('Alice') == ()
Ejemplo n.º 6
0
 def quick_scan(cls):
     """
         Return a very quick list of block devices from
         a number of sources so we can quickly see changes.
     """
     return pipe(fetch_device_list(), cmapcat(getter("paths")), sorted)