本文整理汇总了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)
示例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
示例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())
)
示例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)))
示例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)
示例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)
)
示例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
示例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)
示例9: connection
# 需要导入模块: import toolz [as 别名]
# 或者: from toolz import merge [as 别名]
def connection(connection):
return toolz.merge(connection, {'database': 'test'})
示例10: params
# 需要导入模块: import toolz [as 别名]
# 或者: from toolz import merge [as 别名]
def params(self):
return merge(*self._params)
示例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
)
示例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))
示例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)
示例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)
示例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),
)