当前位置: 首页>>代码示例>>Python>>正文


Python toolz.merge方法代码示例

本文整理汇总了Python中toolz.merge方法的典型用法代码示例。如果您正苦于以下问题:Python toolz.merge方法的具体用法?Python toolz.merge怎么用?Python toolz.merge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在toolz的用法示例。


在下文中一共展示了toolz.merge方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_schema

# 需要导入模块: import toolz [as 别名]
# 或者: from toolz import merge [as 别名]
def _get_schema(self):
        # For joins retaining both table schemas, merge them together here
        left = self.left
        right = self.right

        if not left._is_materialized():
            left = left.materialize()

        if not right._is_materialized():
            right = right.materialize()

        sleft = left.schema()
        sright = right.schema()

        overlap = set(sleft.names) & set(sright.names)
        if overlap:
            raise com.RelationError(
                'Joined tables have overlapping names: %s' % str(list(overlap))
            )

        return sleft.append(sright) 
开发者ID:ibis-project,项目名称:ibis,代码行数:23,代码来源:operations.py

示例2: prepare

# 需要导入模块: import toolz [as 别名]
# 或者: from toolz import merge [as 别名]
def prepare(query, connection=None, external=None):
    connection = merge(_default, connection or {})
    database = escape(connection['database'])
    query = query.format(db=database)
    params = {'database': connection['database'],
              'query': query,
              'user': connection['user'],
              'password': connection['password']}
    params = valfilter(lambda x: x, params)

    files = {}
    external = external or {}
    for name, (structure, serialized) in external.items():
        params['{}_format'.format(name)] = 'CSV'
        params['{}_structure'.format(name)] = structure
        files[name] = serialized

    host = connection['host']

    return host, params, files 
开发者ID:kszucs,项目名称:pandahouse,代码行数:22,代码来源:http.py

示例3: run_example

# 需要导入模块: import toolz [as 别名]
# 或者: from toolz import merge [as 别名]
def run_example(example_name, environ):
    """
    Run an example module from catalyst.examples.
    """
    mod = EXAMPLE_MODULES[example_name]

    register_calendar("YAHOO", get_calendar("NYSE"), force=True)

    return run_algorithm(
        initialize=getattr(mod, 'initialize', None),
        handle_data=getattr(mod, 'handle_data', None),
        before_trading_start=getattr(mod, 'before_trading_start', None),
        analyze=getattr(mod, 'analyze', None),
        bundle='test',
        environ=environ,
        # Provide a default capital base, but allow the test to override.
        **merge({'capital_base': 1e7}, mod._test_args())
    ) 
开发者ID:enigmampc,项目名称:catalyst,代码行数:20,代码来源:__init__.py

示例4: print_training_params

# 需要导入模块: import toolz [as 别名]
# 或者: from toolz import merge [as 别名]
def print_training_params(self, cgs, training_params):

        enc_dec_param_dict = merge(self.encoder.get_params(),
                                   self.decoder.get_params())

        # Print which parameters are excluded
        for k, v in cgs.iteritems():
            excluded_all = list(set(v.parameters) - set(training_params[k]))
            for p in excluded_all:
                logger.info(
                    'Excluding from training of CG[{}]: {}'
                    .format(k, [key for key, val in
                                enc_dec_param_dict.iteritems()
                                if val == p][0]))
            logger.info(
                'Total number of excluded parameters for CG[{}]: [{}]'
                .format(k, len(excluded_all)))

        for k, v in training_params.iteritems():
            for p in v:
                logger.info('Training parameter from CG[{}]: {}'
                            .format(k, p.name))
            logger.info(
                'Total number of parameters will be trained for CG[{}]: [{}]'
                .format(k, len(v))) 
开发者ID:nyu-dl,项目名称:dl4mt-multi,代码行数:27,代码来源:models.py

示例5: combined_evaluators

# 需要导入模块: import toolz [as 别名]
# 或者: from toolz import merge [as 别名]
def combined_evaluators(test_data: pd.DataFrame,
                        evaluators: List[EvalFnType]) -> EvalReturnType:
    """
    Combine partially applies evaluation functions.

    Parameters
    ----------
    test_data : Pandas' DataFrame
        A Pandas' DataFrame to apply the evaluators on

    evaluators: List
        List of evaluator functions

    Returns
    ----------
    log: dict
        A log-like dictionary with the column mean
    """
    return fp.merge(e(test_data) for e in evaluators) 
开发者ID:nubank,项目名称:fklearn,代码行数:21,代码来源:evaluators.py

示例6: pre_execute_multiple_clients

# 需要导入模块: import toolz [as 别名]
# 或者: from toolz import merge [as 别名]
def pre_execute_multiple_clients(node, *clients, scope=None, **kwargs):
    return toolz.merge(
        scope, *map(partial(pre_execute, node, scope=scope, **kwargs), clients)
    ) 
开发者ID:ibis-project,项目名称:ibis,代码行数:6,代码来源:dispatch.py

示例7: compute_sort_key

# 需要导入模块: import toolz [as 别名]
# 或者: from toolz import merge [as 别名]
def compute_sort_key(key, data, scope=None, **kwargs):
    by = key.to_expr()
    try:
        if isinstance(by, str):
            return by, None
        return by.get_name(), None
    except com.ExpressionError:
        new_scope = {t: data for t in by.op().root_tables()}
        new_column = execute(by, scope=toolz.merge(scope, new_scope), **kwargs)
        name = ibis.util.guid()
        new_column.name = name
        return name, new_column 
开发者ID:ibis-project,项目名称:ibis,代码行数:14,代码来源:util.py

示例8: safe_merge

# 需要导入模块: import toolz [as 别名]
# 或者: from toolz import merge [as 别名]
def safe_merge(*maps):
    return None if any(m is None for m in maps) else toolz.merge(*maps) 
开发者ID:ibis-project,项目名称:ibis,代码行数:4,代码来源:maps.py

示例9: connection

# 需要导入模块: import toolz [as 别名]
# 或者: from toolz import merge [as 别名]
def connection(connection):
    return toolz.merge(connection, {'database': 'test'}) 
开发者ID:kszucs,项目名称:pandahouse,代码行数:4,代码来源:test_core.py

示例10: params

# 需要导入模块: import toolz [as 别名]
# 或者: from toolz import merge [as 别名]
def params(self):
        return merge(*self._params) 
开发者ID:daskos,项目名称:daskos,代码行数:4,代码来源:delayed.py

示例11: load_adjusted_array

# 需要导入模块: import toolz [as 别名]
# 或者: from toolz import merge [as 别名]
def load_adjusted_array(self, columns, dates, assets, mask):
        return merge(
            self.get_loader(column).load_adjusted_array(
                [column], dates, assets, mask
            )
            for column in columns
        ) 
开发者ID:zhanghan1990,项目名称:zipline-chinese,代码行数:9,代码来源:events.py

示例12: __init__

# 需要导入模块: import toolz [as 别名]
# 或者: from toolz import merge [as 别名]
def __init__(self, key, mapping=None, **kwargs):
        self._map = {}
        self._sorted_key_names = []
        self._sort_key = key

        self.update(merge(mapping or {}, kwargs)) 
开发者ID:zhanghan1990,项目名称:zipline-chinese,代码行数:8,代码来源:data.py

示例13: test_ewm_stats

# 需要导入模块: import toolz [as 别名]
# 或者: from toolz import merge [as 别名]
def test_ewm_stats(self, window_length):

        def ewma_name(decay_rate):
            return 'ewma_%s' % decay_rate

        def ewmstd_name(decay_rate):
            return 'ewmstd_%s' % decay_rate

        decay_rates = [0.25, 0.5, 0.75]
        ewmas = {
            ewma_name(decay_rate): EWMA(
                inputs=(USEquityPricing.close,),
                window_length=window_length,
                decay_rate=decay_rate,
            )
            for decay_rate in decay_rates
        }

        ewmstds = {
            ewmstd_name(decay_rate): EWMSTD(
                inputs=(USEquityPricing.close,),
                window_length=window_length,
                decay_rate=decay_rate,
            )
            for decay_rate in decay_rates
        }

        all_results = self.engine.run_pipeline(
            Pipeline(columns=merge(ewmas, ewmstds)),
            self.dates[window_length],
            self.dates[-1],
        )

        for decay_rate in decay_rates:
            ewma_result = all_results[ewma_name(decay_rate)].unstack()
            ewma_expected = self.expected_ewma(window_length, decay_rate)
            assert_frame_equal(ewma_result, ewma_expected)

            ewmstd_result = all_results[ewmstd_name(decay_rate)].unstack()
            ewmstd_expected = self.expected_ewmstd(window_length, decay_rate)
            assert_frame_equal(ewmstd_result, ewmstd_expected) 
开发者ID:zhanghan1990,项目名称:zipline-chinese,代码行数:43,代码来源:test_engine.py

示例14: _test_ewm_stats

# 需要导入模块: import toolz [as 别名]
# 或者: from toolz import merge [as 别名]
def _test_ewm_stats(self, window_length):

        def ewma_name(decay_rate):
            return 'ewma_%s' % decay_rate

        def ewmstd_name(decay_rate):
            return 'ewmstd_%s' % decay_rate

        decay_rates = [0.25, 0.5, 0.75]
        ewmas = {
            ewma_name(decay_rate): EWMA(
                inputs=(USEquityPricing.close,),
                window_length=window_length,
                decay_rate=decay_rate,
            )
            for decay_rate in decay_rates
        }

        ewmstds = {
            ewmstd_name(decay_rate): EWMSTD(
                inputs=(USEquityPricing.close,),
                window_length=window_length,
                decay_rate=decay_rate,
            )
            for decay_rate in decay_rates
        }

        all_results = self.engine.run_pipeline(
            Pipeline(columns=merge(ewmas, ewmstds)),
            self.dates[window_length],
            self.dates[-1],
        )

        for decay_rate in decay_rates:
            ewma_result = all_results[ewma_name(decay_rate)].unstack()
            ewma_expected = self.expected_ewma(window_length, decay_rate)
            assert_frame_equal(ewma_result, ewma_expected)

            ewmstd_result = all_results[ewmstd_name(decay_rate)].unstack()
            ewmstd_expected = self.expected_ewmstd(window_length, decay_rate)
            assert_frame_equal(ewmstd_result, ewmstd_expected) 
开发者ID:enigmampc,项目名称:catalyst,代码行数:43,代码来源:test_engine.py

示例15: load_adjusted_array

# 需要导入模块: import toolz [as 别名]
# 或者: from toolz import merge [as 别名]
def load_adjusted_array(self, columns, dates, sids, mask):
        n, p = self.split_next_and_previous_event_columns(columns)
        return merge(
            self.load_next_events(n, dates, sids, mask),
            self.load_previous_events(p, dates, sids, mask),
        ) 
开发者ID:enigmampc,项目名称:catalyst,代码行数:8,代码来源:events.py


注:本文中的toolz.merge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。