77
88import matplotlib .pyplot as plt
99
10- from . import conf
11-
1210if typing .TYPE_CHECKING :
1311 from typing import Any , Optional
1412
1513 from matplotlib .figure import Figure
1614 from numpy import ndarray
1715
16+ from .config import Config
17+ from .stagyydata import StagyyData , _StepsView
18+
19+
20+ def walk (sdat : StagyyData , conf : Config ) -> _StepsView :
21+ """Return view on configured steps slice."""
22+ if conf .core .timesteps :
23+ return sdat .steps [conf .core .timesteps ]
24+ return sdat .snaps [conf .core .snapshots ]
25+
1826
19- def out_name (stem : str , timestep : Optional [int ] = None ) -> str :
27+ def out_name (conf : Config , stem : str , timestep : Optional [int ] = None ) -> str :
2028 """Return StagPy out file name.
2129
2230 Args:
@@ -25,9 +33,6 @@ def out_name(stem: str, timestep: Optional[int] = None) -> str:
2533
2634 Returns:
2735 the output file name.
28-
29- Other Parameters:
30- conf.core.outname: the generic name stem, defaults to ``'stagpy'``.
3136 """
3237 if conf .core .shortname :
3338 return conf .core .outname
@@ -54,7 +59,11 @@ def scilabel(value: float, precision: int = 2) -> str:
5459
5560
5661def saveplot (
57- fig : Figure , * name_args : Any , close : bool = True , ** name_kwargs : Any
62+ conf : Config ,
63+ fig : Figure ,
64+ stem : str ,
65+ timestep : Optional [int ] = None ,
66+ close : bool = True ,
5867) -> None :
5968 """Save matplotlib figure.
6069
@@ -63,11 +72,11 @@ def saveplot(
6372
6473 Args:
6574 fig: the :class:`matplotlib.figure.Figure` to save.
75+ stem: short description of file content.
76+ timestep: timestep if relevant.
6677 close: whether to close the figure.
67- name_args: positional arguments passed on to :func:`out_name`.
68- name_kwargs: keyword arguments passed on to :func:`out_name`.
6978 """
70- oname = out_name (* name_args , ** name_kwargs )
79+ oname = out_name (conf , stem , timestep )
7180 fig .savefig (
7281 f"{ oname } .{ conf .plot .format } " , format = conf .plot .format , bbox_inches = "tight"
7382 )
0 commit comments