Skip to content

Commit 131b7e4

Browse files
committed
refstate: reduce reliance on global conf
1 parent 52f60cd commit 131b7e4

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

stagpy/refstate.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,25 @@
22

33
from __future__ import annotations
44

5+
from typing import Optional
6+
57
import matplotlib.pyplot as plt
68

7-
from . import _helpers, conf
9+
from . import _helpers
10+
from .config import Config
811
from .phyvars import REFSTATE
912
from .stagyydata import StagyyData
1013

1114

12-
def plot_ref(sdat: StagyyData, var: str) -> None:
15+
def plot_ref(sdat: StagyyData, var: str, conf: Optional[Config] = None) -> None:
1316
"""Plot one reference state.
1417
1518
Args:
1619
sdat: a :class:`~stagpy.stagyydata.StagyyData` instance.
1720
var: refstate variable, a key of :data:`~stagpy.phyvars.REFSTATE`.
1821
"""
22+
if conf is None:
23+
conf = Config.default_()
1924
fig, axis = plt.subplots()
2025
adbts = sdat.refstate.adiabats
2126
if len(adbts) > 2:
@@ -44,7 +49,9 @@ def cmd() -> None:
4449
conf.core
4550
conf.plot
4651
"""
52+
from . import conf
53+
4754
sdat = StagyyData(conf.core.path)
4855

4956
for var in conf.refstate.plot:
50-
plot_ref(sdat, var)
57+
plot_ref(sdat, var, conf)

0 commit comments

Comments
 (0)