scripts: csv.py: Ignore missing by fields in enumerate/accumulate
Note this matches the behavior of mods, e.g. I would expect this to not
break if ORDER is missing:
./scripts/csv.py \
-bcase='%(case)s+%(probe)s+%(ORDER)s' \
-ft=accumulate(bench_simtime, case, probe, ORDER)
Normally the expr compiler would force typechecking of ORDER, giving it
a default value of int(0) if missing, but we intentionally bypass
typechecking in enumerate/accumulate's by fields since they may be
strings.
This commit is contained in:
+4
-12
@@ -812,12 +812,8 @@ class CsvExpr:
|
|||||||
return CsvInt(0)
|
return CsvInt(0)
|
||||||
|
|
||||||
# enumerate
|
# enumerate
|
||||||
k = ['enumerate', id(self)]
|
k = ('enumerate', id(self)) + tuple(
|
||||||
for v in self:
|
fields.get(v.a) for v in self)
|
||||||
if v.a not in fields:
|
|
||||||
raise CsvExpr.Error("unknown field? %s" % v.a)
|
|
||||||
k.append(fields[v.a])
|
|
||||||
k = tuple(k)
|
|
||||||
x = state.get(k)
|
x = state.get(k)
|
||||||
if x is None:
|
if x is None:
|
||||||
x = 0
|
x = 0
|
||||||
@@ -852,12 +848,8 @@ class CsvExpr:
|
|||||||
return y
|
return y
|
||||||
|
|
||||||
# accumulate
|
# accumulate
|
||||||
k = ['accumulate', id(self)]
|
k = ('accumulate', id(self)) + tuple(
|
||||||
for v in it.islice(self, 1, None):
|
fields.get(v.a) for v in it.islice(self, 1, None))
|
||||||
if v.a not in fields:
|
|
||||||
raise CsvExpr.Error("unknown field? %s" % v.a)
|
|
||||||
k.append(fields[v.a])
|
|
||||||
k = tuple(k)
|
|
||||||
x = state.get(k)
|
x = state.get(k)
|
||||||
if x is None:
|
if x is None:
|
||||||
x = y
|
x = y
|
||||||
|
|||||||
Reference in New Issue
Block a user