Skip to content

Commit 5ec8f6f

Browse files
committed
rprof: reduce reliance on global conf
1 parent 300704b commit 5ec8f6f

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

stagpy/rprof.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,30 @@
66

77
import matplotlib.pyplot as plt
88

9-
from . import _helpers, conf
9+
from . import _helpers
10+
from .config import Config
1011
from .stagyydata import StagyyData
1112

1213
if typing.TYPE_CHECKING:
13-
from typing import Sequence
14+
from typing import Optional, Sequence
1415

1516
from ._step import Step, _Rprofs
1617

1718

18-
def plot_rprofs(rprofs: _Rprofs, names: Sequence[Sequence[Sequence[str]]]) -> None:
19+
def plot_rprofs(
20+
rprofs: _Rprofs,
21+
names: Sequence[Sequence[Sequence[str]]],
22+
conf: Optional[Config] = None,
23+
) -> None:
1924
"""Plot requested radial profiles.
2025
2126
Args:
2227
rprofs: a radial profile collection, such as :attr:`Step.rprofs` or
2328
:attr:`_StepsView.rprofs_averaged`.
2429
names: profile names organized by figures, plots and subplots.
2530
"""
31+
if conf is None:
32+
conf = Config.default_()
2633
stepstr = rprofs.stepstr
2734
sdat = rprofs.step.sdat
2835

@@ -97,14 +104,16 @@ def cmd() -> None:
97104
conf.rprof
98105
conf.core
99106
"""
107+
from . import conf
108+
100109
sdat = StagyyData(conf.core.path)
101110

102111
if conf.rprof.grid:
103112
for step in sdat.walk.filter(rprofs=True):
104113
plot_grid(step)
105114

106115
if conf.rprof.average:
107-
plot_rprofs(sdat.walk.rprofs_averaged, conf.rprof.plot)
116+
plot_rprofs(sdat.walk.rprofs_averaged, conf.rprof.plot, conf)
108117
else:
109118
for step in sdat.walk.filter(rprofs=True):
110-
plot_rprofs(step.rprofs, conf.rprof.plot)
119+
plot_rprofs(step.rprofs, conf.rprof.plot, conf)

0 commit comments

Comments
 (0)