コード例 #1
0
ファイル: core.py プロジェクト: kasunsp/pinalpha_mvp
 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
コード例 #2
0
ファイル: python.py プロジェクト: nkhuyu/blaze
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)
コード例 #3
0
ファイル: python.py プロジェクト: somu-analyst/blaze
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)
コード例 #4
0
ファイル: test_itertoolz.py プロジェクト: danoneata/toolz
def test_getter():
    assert getter(0)('Alice') == 'A'
    assert getter([0])('Alice') == ('A',)
    assert getter([])('Alice') == ()
コード例 #5
0
ファイル: test_itertoolz.py プロジェクト: zhouyujoe/toolz
def test_getter():
    assert getter(0)('Alice') == 'A'
    assert getter([0])('Alice') == ('A', )
    assert getter([])('Alice') == ()
コード例 #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)