Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_property_(case, arg, expected):
assert _.map_(arg, _.property_(case)) == expected
def test_partial_as_iteratee():
func = _.partial(lambda offset, value, *args: value + offset, 5)
case = [1, 2, 3]
expected = [6, 7, 8]
_.map_(case, func) == expected
def test_map_(case, expected, sort_results):
actual = _.map_(*case)
if sort_results:
actual = sorted(actual)
assert actual == expected
def test_annotated_iteratee():
assert _.map_([1, 2], typed_function) == [2, 3]
:type main_market_filter: str
:return: All Bittrex markets (with filter applied, if any)
:rtype: list
"""
markets = self.Bittrex.get_markets()
if not markets["success"]:
error_str = self.Messenger.print_error("market", [], True)
logger.error(error_str)
exit()
markets = markets["result"]
if main_market_filter is not None:
market_check = main_market_filter + "-"
markets = py_.filter_(markets, lambda market: market_check in market["MarketName"])
markets = py_.map_(markets, lambda market: market["MarketName"])
return markets
Returns:
dict: Results of omitting properties.
Example:
>>> omit_by({'a': 1, 'b': '2', 'c': 3}, lambda v: isinstance(v, int))
{'b': '2'}
.. versionadded:: 4.0.0
.. versionchanged:: 4.2.0
Support deep paths for `iteratee`.
"""
if not callable(iteratee):
paths = pyd.map_(iteratee, to_path)
if any(len(path) > 1 for path in paths):
cloned = clone_deep(obj)
else:
cloned = to_dict(obj)
def _unset(obj, path):
pyd.unset(obj, path)
return obj
ret = pyd.reduce_(paths, _unset, cloned)
else:
argcount = getargcount(iteratee, maxargs=2)
ret = {key: value for key, value in iterator(obj)
if not callit(iteratee, value, key, argcount=argcount)}
Example:
>>> join(['a', 'b', 'c']) == 'abc'
True
>>> join([1, 2, 3, 4], '&') == '1&2&3&4'
True
>>> join('abcdef', '-') == 'a-b-c-d-e-f'
True
.. versionadded:: 2.0.0
.. versionchanged:: 4.0.0
Removed alias ``implode``.
"""
return pyd.to_string(separator).join(pyd.map_(array or (), pyd.to_string))
if len(xoxo) > 0 and xoxo[0] != None:
with open(str(xoxo[0]['output']), 'w') as makefile:
for item in xoxo:
object_id = str(item['darkchocolate'][0])
center_x = str(item['darkchocolate'][1])
center_y = str(item['darkchocolate'][2])
width = str(item['darkchocolate'][3])
height = str(item['darkchocolate'][4])
spaces = object_id + " " + center_x + " " + center_y + " " + width + " " + height
makefile.write('%s\n' % spaces)
return _.map_([pos_json for pos_json in os.listdir(_path)
if pos_json.endswith('.json')],
lambda x: ingredients(x, _path))
Args:
array (list): List to map and concatenate.
iteratee (mixed): Iteratee to apply to each element.
Returns:
list: Mapped and concatenated list.
Example:
>>> mapcat(range(4), lambda x: list(range(x)))
[0, 0, 1, 0, 1, 2]
.. versionadded:: 2.0.0
"""
return concat(*pyd.map_(array, iteratee))
def create_label(y_col, x_col, title=None, y_title=None, x_title=None, legend_name=None):
'''Create label dict for go.Layout with smart resolution'''
legend_name = legend_name or y_col
y_col_list, x_col_list, legend_name_list = ps.map_(
[y_col, x_col, legend_name], util.cast_list)
y_title = str(y_title or ','.join(y_col_list))
x_title = str(x_title or ','.join(x_col_list))
title = title or f'{y_title} vs {x_title}'
label = {
'y_title': y_title,
'x_title': x_title,
'title': title,
'y_col_list': y_col_list,
'x_col_list': x_col_list,
'legend_name_list': legend_name_list,
}
return label