當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。