Skip to content

Commit 945d647

Browse files
committed
Fix error tolerance test.
Was pruning when no error tolerance set.
1 parent f6e45b9 commit 945d647

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

python/MaterialXTest/tests_to_html.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def main(args=None):
5353
parser.add_argument('-l1', '--lang1', dest='lang1', action='store', help='First target language for comparison. Default is glsl', default="glsl")
5454
parser.add_argument('-l2', '--lang2', dest='lang2', action='store', help='Second target language for comparison. Default is osl', default="osl")
5555
parser.add_argument('-l3', '--lang3', dest='lang3', action='store', help='Third target language for comparison. Default is empty', default="")
56-
parser.add_argument('-e', '--error', dest='error', action='store', help='Tolerance: only write rows where any RMS diff is greater than this (applies only when --diff is set). Default 0.', default=0, type=float)
56+
parser.add_argument('-e', '--error', dest='error', action='store', help='Tolerance threshold. Default -1 disables pruning. When > 0 (and --diff is set), rows with all RMS < tolerance are omitted.', default=-1, type=float)
5757
parser.add_argument('-f', '--format', dest='format', choices=['html', 'json', 'markdown'], help='Output format: html, json, or markdown', default='html')
5858

5959
args = parser.parse_args(args)
@@ -171,17 +171,19 @@ def build_groups():
171171
diffPath3 = base_prefix + "_" + args.lang2 + "-2_vs_" + args.lang3 + "-3_diff.png"
172172
diffRms3 = computeDiff(fullPath2, fullPath3, diffPath3)
173173

174-
# If diffing is enabled, only write a row when any computed RMS exceeds tolerance
175-
if args.CREATE_DIFF and DIFF_ENABLED:
174+
# Row filtering based on tolerance:
175+
# - If error < 0: do not prune (always include rows)
176+
# - If error > 0: prune rows where all computed RMS values are below the threshold
177+
if args.CREATE_DIFF and DIFF_ENABLED and args.error > 0:
176178
diffs_present = []
177179
if diffRms1 is not None:
178180
diffs_present.append(diffRms1)
179181
if diffRms2 is not None:
180182
diffs_present.append(diffRms2)
181183
if diffRms3 is not None:
182184
diffs_present.append(diffRms3)
183-
# If no diffs were computed or none exceed tolerance, skip the row
184-
if not any(d > args.error for d in diffs_present):
185+
# If we have at least one diff value and all are below the threshold, skip this row
186+
if diffs_present and all(d < args.error for d in diffs_present):
185187
continue
186188

187189
# Detect group change and create group container (ensure not None)

0 commit comments

Comments
 (0)