Updating cyclic zip
This commit is contained in:
@ -64,12 +64,14 @@ def resolve_item(item: Meta, options: dict):
|
|||||||
run=opt_item,
|
run=opt_item,
|
||||||
text=item.text,
|
text=item.text,
|
||||||
kwargs=(options | item.local_options),
|
kwargs=(options | item.local_options),
|
||||||
|
local_options=item.local_options
|
||||||
)
|
)
|
||||||
elif isinstance(opt_item, str):
|
elif isinstance(opt_item, str):
|
||||||
yield Sample(
|
yield Sample(
|
||||||
name=opt_item,
|
name=opt_item,
|
||||||
text=item.text,
|
text=item.text,
|
||||||
kwargs=(options | item.local_options),
|
kwargs=(options | item.local_options),
|
||||||
|
local_options=item.local_options
|
||||||
)
|
)
|
||||||
variable = deepcopy(opt_item)
|
variable = deepcopy(opt_item)
|
||||||
yield from resolve_item(variable, options)
|
yield from resolve_item(variable, options)
|
||||||
@ -84,6 +86,7 @@ def resolve_item(item: Meta, options: dict):
|
|||||||
run=opt_item,
|
run=opt_item,
|
||||||
text=var.text,
|
text=var.text,
|
||||||
kwargs=(options | var.local_options),
|
kwargs=(options | var.local_options),
|
||||||
|
local_options=var.local_options
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
elif isinstance(opt_item, str):
|
elif isinstance(opt_item, str):
|
||||||
@ -92,6 +95,7 @@ def resolve_item(item: Meta, options: dict):
|
|||||||
name=opt_item,
|
name=opt_item,
|
||||||
text=var.text,
|
text=var.text,
|
||||||
kwargs=(options | var.local_options),
|
kwargs=(options | var.local_options),
|
||||||
|
local_options=var.local_options
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
elif isinstance(opt_item, Sequence):
|
elif isinstance(opt_item, Sequence):
|
||||||
@ -376,6 +380,7 @@ class ListOperation(Sequence):
|
|||||||
flattened_list.extend(list(item.evaluate(options)))
|
flattened_list.extend(list(item.evaluate(options)))
|
||||||
elif isinstance(item, (Event, RandomInteger, Integer)):
|
elif isinstance(item, (Event, RandomInteger, Integer)):
|
||||||
item.update_options(options)
|
item.update_options(options)
|
||||||
|
item = update_item(item, options)
|
||||||
flattened_list.append(item)
|
flattened_list.append(item)
|
||||||
|
|
||||||
if isinstance(input_list, Sequence):
|
if isinstance(input_list, Sequence):
|
||||||
|
|||||||
@ -99,14 +99,15 @@ def cyclic_zip(first: list, second: list) -> list:
|
|||||||
"""Cyclic zip method
|
"""Cyclic zip method
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
first (list): First list
|
first (list): First list is cycled
|
||||||
second (list): Second list
|
second (list): Second list
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
list: Cyclicly zipped list
|
list: Cyclicly zipped list
|
||||||
"""
|
"""
|
||||||
max_length = max(len(first), len(second))
|
|
||||||
result = []
|
result = []
|
||||||
for i in range(max_length):
|
s_length = len(second)
|
||||||
result.append([first[i % len(first)], second[i % len(second)]])
|
f_length = len(first)
|
||||||
|
for i in range(s_length):
|
||||||
|
result.append([first[i % f_length], second[i]])
|
||||||
return [deepcopy(item) for sublist in result for item in sublist]
|
return [deepcopy(item) for sublist in result for item in sublist]
|
||||||
|
|||||||
Reference in New Issue
Block a user