Skip to content

Commit 22e1589

Browse files
authored
Merge pull request #214 from boutproject/animate_list-per-var-kwargs
Allow lists to be passed for kwargs in BoutDataset.animate_list()
2 parents e072830 + 3be05f3 commit 22e1589

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

xbout/boutdataset.py

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,8 @@ def animate_list(
921921
If a dict is passed, the dict entries are passed as arguments to
922922
tight_layout()
923923
**kwargs : dict, optional
924-
Additional keyword arguments are passed on to each animation function
924+
Additional keyword arguments are passed on to each animation function, per
925+
variable if a sequence is given.
925926
926927
Returns
927928
-------
@@ -976,6 +977,8 @@ def _expand_list_arg(arg, arg_name):
976977
aspect = _expand_list_arg(aspect, "aspect")
977978
extend = _expand_list_arg(extend, "extend")
978979
axis_coords = _expand_list_arg(axis_coords, "axis_coords")
980+
for k in kwargs:
981+
kwargs[k] = _expand_list_arg(kwargs[k], k)
979982

980983
blocks = []
981984

@@ -986,17 +989,19 @@ def is_list(variable):
986989
or isinstance(variable, set)
987990
)
988991

989-
for subplot_args in zip(
990-
variables,
991-
axes,
992-
poloidal_plot,
993-
axis_coords,
994-
vmin,
995-
vmax,
996-
logscale,
997-
titles,
998-
aspect,
999-
extend,
992+
for i, subplot_args in enumerate(
993+
zip(
994+
variables,
995+
axes,
996+
poloidal_plot,
997+
axis_coords,
998+
vmin,
999+
vmax,
1000+
logscale,
1001+
titles,
1002+
aspect,
1003+
extend,
1004+
)
10001005
):
10011006

10021007
(
@@ -1012,6 +1017,8 @@ def is_list(variable):
10121017
this_extend,
10131018
) = subplot_args
10141019

1020+
this_kwargs = {k: v[i] for k, v in kwargs.items()}
1021+
10151022
divider = make_axes_locatable(ax)
10161023
cax = divider.append_axes("right", size="5%", pad=0.1)
10171024

@@ -1051,7 +1058,7 @@ def is_list(variable):
10511058
animate=False,
10521059
axis_coords=this_axis_coords,
10531060
aspect=this_aspect,
1054-
**kwargs,
1061+
**this_kwargs,
10551062
)
10561063
)
10571064
else:
@@ -1065,7 +1072,7 @@ def is_list(variable):
10651072
axis_coords=this_axis_coords,
10661073
aspect=this_aspect,
10671074
label=w.name,
1068-
**kwargs,
1075+
**this_kwargs,
10691076
)
10701077
)
10711078
legend = ax.legend()
@@ -1086,7 +1093,7 @@ def is_list(variable):
10861093
logscale=this_logscale,
10871094
aspect=this_aspect,
10881095
extend=this_extend,
1089-
**kwargs,
1096+
**this_kwargs,
10901097
)
10911098
for block in var_blocks:
10921099
blocks.append(block)
@@ -1104,7 +1111,7 @@ def is_list(variable):
11041111
logscale=this_logscale,
11051112
aspect=this_aspect,
11061113
extend=this_extend,
1107-
**kwargs,
1114+
**this_kwargs,
11081115
)
11091116
)
11101117
else:

0 commit comments

Comments
 (0)