Skip to content

Commit ec68f7a

Browse files
committed
Fix type of conf.time.marktimes
1 parent 7b61723 commit ec68f7a

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

stagpy/config.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
from loam.tools import switch_opt, config_conf_section, set_conf_opt
1212

1313

14-
def _actual_index(arg):
15-
"""Turn a string in a integer or slice."""
14+
def _slice_or_int(arg):
15+
"""Parse a string into an integer or slice."""
1616
if ':' in arg:
1717
idxs = arg.split(':')
1818
if len(idxs) > 3:
@@ -27,15 +27,15 @@ def _actual_index(arg):
2727
return int(arg)
2828

2929

30-
def _index_collection(arg):
31-
"""Build an index collection from a command line input."""
32-
return [_actual_index(item) for item in arg.split(',') if item]
30+
def _list_of(from_str):
31+
"""Return fn parsing a str as a comma-separated list of given type."""
32+
def parser(arg):
33+
return tuple(from_str(v) for v in map(str.strip, arg.split(',')) if v)
34+
return parser
3335

3436

35-
def _float_list(arg):
36-
"""Build a tuple of floats from a command line input."""
37-
return tuple(float(val) for val in arg.split(',') if val)
38-
37+
_index_collection = _list_of(_slice_or_int)
38+
_float_list = _list_of(float)
3939

4040
HOME_DIR = pathlib.Path.home()
4141
CONFIG_DIR = HOME_DIR / '.config' / 'stagpy'
@@ -164,7 +164,7 @@ def _float_list(arg):
164164
Conf(None, True, None, {'type': float},
165165
False, 'ending fraction of series to process')),
166166
('marktimes',
167-
Conf('', True, 'M', {},
167+
Conf('', True, 'M', {'type': _float_list},
168168
False, 'list of times where to put a mark')),
169169
('marksteps',
170170
Conf('', True, 'T', {'type': _index_collection},
@@ -187,7 +187,7 @@ def _float_list(arg):
187187
CONF_DEF['plates'] = OrderedDict((
188188
('plot',
189189
Conf('c.T.v2-v2.dv2-v2.topo_top', True, 'o',
190-
{'nargs': '?', 'const': '', 'type': str}, True,
190+
{'nargs': '?', 'const': ''}, True,
191191
'variables to plot, can be a surface field, field, or dv2')),
192192
('field',
193193
Conf('eta', True, None, {},

stagpy/time_series.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111

1212
def _collect_marks(sdat):
1313
"""Concatenate mark* config variable."""
14-
times = set(conf.time.marktimes.replace(',', ' ').split())
15-
times = list(map(float, times))
14+
times = list(conf.time.marktimes)
1615
times.extend(step.timeinfo['t']
1716
for step in sdat.snaps[conf.time.marksnaps])
1817
times.extend(step.timeinfo['t']

0 commit comments

Comments
 (0)