diff --git a/scripts/code.py b/scripts/code.py index bb004c3d..7cc06958 100755 --- a/scripts/code.py +++ b/scripts/code.py @@ -572,7 +572,7 @@ def fold(Result, results, *, Result._children: fold( Result, getattr(r, Result._children), by=by, - defines=defines, + # only filter defines at the top level! sort=sort, depth=depth-1)}) for r in folded] diff --git a/scripts/cov.py b/scripts/cov.py index 65775e58..48f23bd5 100755 --- a/scripts/cov.py +++ b/scripts/cov.py @@ -433,7 +433,7 @@ def fold(Result, results, *, Result._children: fold( Result, getattr(r, Result._children), by=by, - defines=defines, + # only filter defines at the top level! sort=sort, depth=depth-1)}) for r in folded] diff --git a/scripts/csv.py b/scripts/csv.py index 5c59bc9b..ce73603d 100755 --- a/scripts/csv.py +++ b/scripts/csv.py @@ -1412,7 +1412,6 @@ def compile(fields_, results, fields=None, mods=[], exprs=[], - defines=[], sort=None, children=None, hot=None, @@ -1420,10 +1419,6 @@ def compile(fields_, results, by = by.copy() fields = fields.copy() - # make sure define fields are included - for k, _ in defines: - if k not in by and k not in fields: - by.append(k) # make sure sort/hot fields are included for k, reverse in it.chain(sort or [], hot or []): # this defaults to typechecking sort/hot fields, which is @@ -1562,20 +1557,32 @@ def compile(fields_, results, def homogenize(Result, results, *, enumerates=None, + defines=[], depth=1): # this just converts all (possibly recursive) results to our # result type results_ = [] - for i, r in enumerate(results): + for r in results: + # filter by matching defines + # + # we do this here instead of in fold to be consistent with + # evaluation order of exprs/mods/etc, note this isn't really + # inconsistent with the other scripts, since they don't really + # evaluate anything + if not all(k in r and str(r[k]) in vs for k, vs in defines): + continue + + # append a result results_.append(Result(**( r # enumerate? - | ({e: i for e in enumerates} + | ({e: len(results_) for e in enumerates} if enumerates is not None else {}) # recurse? | ({Result._children: homogenize( Result, r[Result._children], + # only filter defines at the top level! enumerates=enumerates, depth=depth-1)} if hasattr(Result, '_children') @@ -1661,7 +1668,7 @@ def fold(Result, results, *, Result._children: fold( Result, getattr(r, Result._children), by=by, - defines=defines, + # only filter defines at the top level! sort=sort, depth=depth-1)}) for r in folded] @@ -2260,7 +2267,6 @@ def main(csv_paths, *, fields=fields, mods=mods, exprs=exprs, - defines=defines, sort=sort, children=children, hot=hot, @@ -2269,12 +2275,12 @@ def main(csv_paths, *, # homogenize results = homogenize(Result, results, enumerates=enumerates, + defines=defines, depth=depth) # fold results = fold(Result, results, by=by, - defines=defines, depth=depth) # hotify? diff --git a/scripts/ctx.py b/scripts/ctx.py index 8a2fcb54..c85d4152 100755 --- a/scripts/ctx.py +++ b/scripts/ctx.py @@ -783,7 +783,7 @@ def fold(Result, results, *, Result._children: fold( Result, getattr(r, Result._children), by=by, - defines=defines, + # only filter defines at the top level! sort=sort, depth=depth-1)}) for r in folded] diff --git a/scripts/data.py b/scripts/data.py index 3665d8cf..a1cbc573 100755 --- a/scripts/data.py +++ b/scripts/data.py @@ -572,7 +572,7 @@ def fold(Result, results, *, Result._children: fold( Result, getattr(r, Result._children), by=by, - defines=defines, + # only filter defines at the top level! sort=sort, depth=depth-1)}) for r in folded] diff --git a/scripts/perf.py b/scripts/perf.py index 4aa31f6a..fde71e8d 100755 --- a/scripts/perf.py +++ b/scripts/perf.py @@ -887,7 +887,7 @@ def fold(Result, results, *, Result._children: fold( Result, getattr(r, Result._children), by=by, - defines=defines, + # only filter defines at the top level! sort=sort, depth=depth-1)}) for r in folded] diff --git a/scripts/perfbd.py b/scripts/perfbd.py index 645dda3c..8408c169 100755 --- a/scripts/perfbd.py +++ b/scripts/perfbd.py @@ -857,7 +857,7 @@ def fold(Result, results, *, Result._children: fold( Result, getattr(r, Result._children), by=by, - defines=defines, + # only filter defines at the top level! sort=sort, depth=depth-1)}) for r in folded] diff --git a/scripts/stack.py b/scripts/stack.py index 405635e7..c1a28fb9 100755 --- a/scripts/stack.py +++ b/scripts/stack.py @@ -529,7 +529,7 @@ def fold(Result, results, *, Result._children: fold( Result, getattr(r, Result._children), by=by, - defines=defines, + # only filter defines at the top level! sort=sort, depth=depth-1)}) for r in folded] diff --git a/scripts/structs.py b/scripts/structs.py index 93a1d760..c52c50a2 100755 --- a/scripts/structs.py +++ b/scripts/structs.py @@ -603,7 +603,7 @@ def fold(Result, results, *, Result._children: fold( Result, getattr(r, Result._children), by=by, - defines=defines, + # only filter defines at the top level! sort=sort, depth=depth-1)}) for r in folded]