Loading examples/rules.yaml +1 −1 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ docs: nrs: 1 cpu: 1 out: txt: file_*n*.txt # 1 txt: file_{n}.txt # 1 script: | # 3 echo {n} >{out[txt]} Loading examples/targets.yaml +1 −1 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ Cov2: out: xtc: run.xtc loop: n: [0, "{replicas}"] # range(0,10) n: "range({replicas})" # range(10) out: txt: file_{n:02d}.txt Loading fmatch.py +3 −3 Original line number Diff line number Diff line import re _var_re = re.compile(r"\*([^*]*)\*") _var_re = re.compile(r"{([^}]*)}") # Note: a match-tree could be used to speed up the process # of finding matching entries, but it's overkill here. class FMatch: # Parse 'test_*u*.dat' into # Parse 'test_{u}.dat' into # start: 'test_' # end: '.dat' # var: 'u' Loading Loading @@ -70,5 +70,5 @@ class FMatch: def __str__(self): if self.var is None: return self.start return '%s*%s*%s'%(self.start, self.var, self.end) return '%s{%s}%s'%(self.start, self.var, self.end) graph.py +4 −5 Original line number Diff line number Diff line Loading @@ -25,11 +25,10 @@ def gen_targets(params): for var, r in params['loop'].items(): if var is not 'out': break assert isinstance(r, list), "Loop must have a single variable holding a range list." for i in range(len(r)): if isinstance(r[i], str) and '{' in r[i]: r[i] = yaml.safe_load(r[i].format(**params)) for n in range(*r): assert isinstance(r, str), "Loop must have a single variable holding an expr." if '{' in r: r = r.format(**params) for n in eval(r, {}, {}): for ttype, out in params['loop']['out'].items(): fmt = {var: n} yield ttype, out.format(**fmt) Loading tests/test_fmatch.py +7 −7 Original line number Diff line number Diff line Loading @@ -3,17 +3,17 @@ from fmatch import * class TestFMatch(unittest.TestCase): def test_var(self): f = FMatch("inp_*nm*.txt") f = FMatch("inp_{nm}.txt") self.assertEqual(f.var, 'nm') f = FMatch("inp.txt") self.assertEqual(f.var, None) f = FMatch("inp_*x*.*t*xt") f = FMatch("inp_{x}.{t}xt") self.assertEqual(f.var, 'x') self.assertEqual(f.end, '.*t*xt') self.assertEqual(f.end, '.{t}xt') def test_same(self): f1 = FMatch("inp_*nm*.txt") f2 = FMatch("in*x*.txt") f1 = FMatch("inp_{nm}.txt") f2 = FMatch("in{x}.txt") f3 = FMatch("inp.txt") self.assertTrue(f1.same(f2)) self.assertTrue(f2.same(f1)) Loading @@ -23,7 +23,7 @@ class TestFMatch(unittest.TestCase): self.assertTrue(f3.same(f2)) def test_match(self): f = FMatch("remd_*m*.trr") f = FMatch("remd_{m}.trr") m = f.match("remd_04.trr") self.assertEqual(m[0], 'm') self.assertEqual(m[1], '04') Loading @@ -33,7 +33,7 @@ class TestFMatch(unittest.TestCase): self.assertTrue(f2.match("spooky")) def test_matched(self): f = FMatch("remd_*m*.trr") f = FMatch("remd_{m}.trr") self.assertEqual(f.matched("04"), "remd_04.trr") if __name__ == '__main__': Loading Loading
examples/rules.yaml +1 −1 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ docs: nrs: 1 cpu: 1 out: txt: file_*n*.txt # 1 txt: file_{n}.txt # 1 script: | # 3 echo {n} >{out[txt]} Loading
examples/targets.yaml +1 −1 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ Cov2: out: xtc: run.xtc loop: n: [0, "{replicas}"] # range(0,10) n: "range({replicas})" # range(10) out: txt: file_{n:02d}.txt Loading
fmatch.py +3 −3 Original line number Diff line number Diff line import re _var_re = re.compile(r"\*([^*]*)\*") _var_re = re.compile(r"{([^}]*)}") # Note: a match-tree could be used to speed up the process # of finding matching entries, but it's overkill here. class FMatch: # Parse 'test_*u*.dat' into # Parse 'test_{u}.dat' into # start: 'test_' # end: '.dat' # var: 'u' Loading Loading @@ -70,5 +70,5 @@ class FMatch: def __str__(self): if self.var is None: return self.start return '%s*%s*%s'%(self.start, self.var, self.end) return '%s{%s}%s'%(self.start, self.var, self.end)
graph.py +4 −5 Original line number Diff line number Diff line Loading @@ -25,11 +25,10 @@ def gen_targets(params): for var, r in params['loop'].items(): if var is not 'out': break assert isinstance(r, list), "Loop must have a single variable holding a range list." for i in range(len(r)): if isinstance(r[i], str) and '{' in r[i]: r[i] = yaml.safe_load(r[i].format(**params)) for n in range(*r): assert isinstance(r, str), "Loop must have a single variable holding an expr." if '{' in r: r = r.format(**params) for n in eval(r, {}, {}): for ttype, out in params['loop']['out'].items(): fmt = {var: n} yield ttype, out.format(**fmt) Loading
tests/test_fmatch.py +7 −7 Original line number Diff line number Diff line Loading @@ -3,17 +3,17 @@ from fmatch import * class TestFMatch(unittest.TestCase): def test_var(self): f = FMatch("inp_*nm*.txt") f = FMatch("inp_{nm}.txt") self.assertEqual(f.var, 'nm') f = FMatch("inp.txt") self.assertEqual(f.var, None) f = FMatch("inp_*x*.*t*xt") f = FMatch("inp_{x}.{t}xt") self.assertEqual(f.var, 'x') self.assertEqual(f.end, '.*t*xt') self.assertEqual(f.end, '.{t}xt') def test_same(self): f1 = FMatch("inp_*nm*.txt") f2 = FMatch("in*x*.txt") f1 = FMatch("inp_{nm}.txt") f2 = FMatch("in{x}.txt") f3 = FMatch("inp.txt") self.assertTrue(f1.same(f2)) self.assertTrue(f2.same(f1)) Loading @@ -23,7 +23,7 @@ class TestFMatch(unittest.TestCase): self.assertTrue(f3.same(f2)) def test_match(self): f = FMatch("remd_*m*.trr") f = FMatch("remd_{m}.trr") m = f.match("remd_04.trr") self.assertEqual(m[0], 'm') self.assertEqual(m[1], '04') Loading @@ -33,7 +33,7 @@ class TestFMatch(unittest.TestCase): self.assertTrue(f2.match("spooky")) def test_matched(self): f = FMatch("remd_*m*.trr") f = FMatch("remd_{m}.trr") self.assertEqual(f.matched("04"), "remd_04.trr") if __name__ == '__main__': Loading