當前位置: 首頁>>代碼示例>>Python>>正文


Python toolz.identity方法代碼示例

本文整理匯總了Python中toolz.identity方法的典型用法代碼示例。如果您正苦於以下問題:Python toolz.identity方法的具體用法?Python toolz.identity怎麽用?Python toolz.identity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在toolz的用法示例。


在下文中一共展示了toolz.identity方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: execute_series_lead_lag

# 需要導入模塊: import toolz [as 別名]
# 或者: from toolz import identity [as 別名]
def execute_series_lead_lag(op, data, offset, default, **kwargs):
    func = toolz.identity if isinstance(op, ops.Lag) else operator.neg
    result = data.shift(func(1 if offset is None else offset))
    return post_lead_lag(result, default) 
開發者ID:ibis-project,項目名稱:ibis,代碼行數:6,代碼來源:window.py

示例2: format_results

# 需要導入模塊: import toolz [as 別名]
# 或者: from toolz import identity [as 別名]
def format_results(terminal_width, key_list, separator, text_list,
                   left_align=True, min_factor=3, **kwargs):
    """Returns formatted results in two columns.
    """
    key_width = max(map(len, key_list))
    separator_length = len(separator)
    desc_wrap = toolz.identity
    if terminal_width:
        if key_width / terminal_width > .5:
            key_width = terminal_width // 2 - 3
        text_width = terminal_width - key_width - separator_length
        if text_width * min_factor > terminal_width:
            desc_wrap = toolz.compose(
                ('\n' + ' ' * (key_width + separator_length)).join,
                toolz.partial(textwrap.wrap, width=text_width, **kwargs),
            )

    if left_align:
        fmt = '%-*s%s%s'
    else:
        fmt = '%*s%s%s'

    for key, text in zip(key_list, text_list):
        text = desc_wrap(text)
        if len(key) > key_width:
            yield fmt % (key_width, key, separator, '')
            yield fmt % (key_width, '', ' ' * separator_length, text)
        else:
            yield fmt % (key_width, key, separator, text) 
開發者ID:rmax,項目名稱:databrewer,代碼行數:31,代碼來源:utils.py

示例3: __init__

# 需要導入模塊: import toolz [as 別名]
# 或者: from toolz import identity [as 別名]
def __init__(self, func=tz.identity, inverse=None, name=None):
        self.func = func
        self._inverse_func = inverse
        self.name = name

        if func is tz.identity:
            self._inverse_func = tz.identity 
開發者ID:napari,項目名稱:napari,代碼行數:9,代碼來源:transforms.py

示例4: apply_async

# 需要導入模塊: import toolz [as 別名]
# 或者: from toolz import identity [as 別名]
def apply_async(f, args=(), kwargs=None, callback=None):
        """Apply a function but emulate the API of an asynchronous call.

        Parameters
        ----------
        f : callable
            The function to call.
        args : tuple, optional
            The positional arguments.
        kwargs : dict, optional
            The keyword arguments.

        Returns
        -------
        future : ApplyAsyncResult
            The result of calling the function boxed in a future-like api.

        Notes
        -----
        This calls the function eagerly but wraps it so that ``SequentialPool``
        can be used where a :class:`multiprocessing.Pool` or
        :class:`gevent.pool.Pool` would be used.
        """
        try:
            value = (identity if callback is None else callback)(
                f(*args, **kwargs or {}),
            )
            successful = True
        except Exception as e:
            value = e
            successful = False

        return ApplyAsyncResult(value, successful) 
開發者ID:enigmampc,項目名稱:catalyst,代碼行數:35,代碼來源:pool.py


注:本文中的toolz.identity方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。