@@ -67,15 +67,15 @@ def as_individual_args(*args, **kwargs):
67
67
# Check that all list arguments have the same length,
68
68
# and find out what that length is
69
69
# If there are no list arguments, length is 1
70
- list_lengths = [len (v ) for v in args + tuple (kwargs .values ()) if isinstance (v , list )]
70
+ list_lengths = [
71
+ len (v ) for v in args + tuple (kwargs .values ()) if isinstance (v , list )
72
+ ]
71
73
if list_lengths and len (set (list_lengths )) > 1 :
72
74
raise ValueError ("All list arguments must have the same length." )
73
75
list_length = list_lengths [0 ] if list_lengths else 1
74
76
75
77
# Expand all arguments to lists of the same length
76
- expanded_args = [
77
- [v ] * list_length if not isinstance (v , list ) else v for v in args
78
- ]
78
+ expanded_args = [[v ] * list_length if not isinstance (v , list ) else v for v in args ]
79
79
expanded_kwargs = {
80
80
k : [v ] * list_length if not isinstance (v , list ) else v
81
81
for k , v in kwargs .items ()
@@ -87,7 +87,9 @@ def as_individual_args(*args, **kwargs):
87
87
88
88
# Reshape into a list of dictionaries
89
89
# Each dictionary represents the keyword arguments for a single function call
90
- list_of_kwargs = [{k : v [i ] for k , v in expanded_kwargs .items ()} for i in range (list_length )]
90
+ list_of_kwargs = [
91
+ {k : v [i ] for k , v in expanded_kwargs .items ()} for i in range (list_length )
92
+ ]
91
93
92
94
return list_of_args , list_of_kwargs
93
95
0 commit comments