Skip to content

Commit 8b9140b

Browse files
lukstaficlaude
andcommitted
Strengthen dimension label tests to verify label preservation
Address reviewer feedback: tests that claim label preservation or propagation now explicitly verify the label string (via row_to_labels or Shape.to_labels), not just absence of exceptions. Key changes: - Add get_var_label helper using Row.row_to_labels to inspect labels - Add test 5b: verifies variable label upgrade in the environment - Tests 1, 3: verify label visible in result shape via Shape.to_labels - Tests 9, 11: restructure concat tests to use variable components (triggers s_dim_one collapse), verify label="x" and d=5 - Tests 12, 14-17: verify label="x" on solved dims after affine/stride arithmetic, not just absence of errors - Test 18: assert definite Shape_error for mutual inequality with conflicting labels, instead of accepting either outcome Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 6ed0fa6 commit 8b9140b

2 files changed

Lines changed: 156 additions & 85 deletions

File tree

test/einsum/test_dimension_labels.expected

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ Found 0, in the config file
33
=== Dimension Label Tests ===
44

55
Test 1: Same label, same size -- succeeds
6-
PASS: same label unification succeeded
6+
Result labels: [batch]
7+
PASS: label preserved in result
78

89
Test 2: Conflicting labels, same size -- raises
910
PASS: got expected Shape_error: solved dimensions for axis: different labels
1011

1112
Test 3: One labeled, one unlabeled, same size -- compatible
13+
Result labels: [batch]
1214
PASS: labeled + unlabeled compatible
1315

1416
Test 4: Variable-mediated: unlabeled first, labeled later -- compatible
@@ -17,6 +19,10 @@ Test 4: Variable-mediated: unlabeled first, labeled later -- compatible
1719
Test 5: Variable-mediated: unlabeled, labeled, then conflicting -- raises
1820
PASS: got expected Shape_error: solved dimensions for axis: different labels
1921

22+
Test 5b: Variable-mediated: label upgrade verified in environment
23+
Var v label after upgrade: "batch"
24+
PASS: variable label upgraded to "batch"
25+
2026
Test 6: Shape.to_labels after inference
2127
Labels: [batch]
2228
PASS: label visible in Shape.to_labels
@@ -30,39 +36,40 @@ Test 8: Operation.range ~axis_label
3036
PASS: range axis_label survives inference
3137

3238
Test 9: Concat, consistent labels -- label preserved
33-
Not fully solved
34-
PASS: concat with consistent labels did not raise
39+
Solved to d=5, label="x"
40+
PASS: concat preserved label "x" with d=5
3541

3642
Test 10: Concat, conflicting labels -- raises
3743
PASS: got expected Shape_error: concat: conflicting dimension labels
3844

3945
Test 11: Concat, mix labeled/unlabeled -- label preserved
40-
Not fully solved
41-
PASS: concat with mixed labels did not raise
46+
Solved to d=5, label="x"
47+
PASS: concat preserved label "x" from labeled component
4248

4349
Test 12: Affine, matching labels -- preserved
44-
Solved to d=6
45-
PASS: affine with matching labels did not raise
50+
Solved to d=6, label="x"
51+
PASS: affine preserved label "x" with d=6
4652

4753
Test 13: Affine, conflicting labels -- raises
4854
PASS: got expected Shape_error: convolution: conflicting dimension labels between stride and kernel
4955

5056
Test 14: Stride no-conv forward -- label propagated
51-
PASS: stride forward with matching labels succeeded
57+
Solved to d=8, label="x"
58+
PASS: stride forward propagated label "x"
5259

5360
Test 15: Stride no-conv reverse -- label propagated
54-
Solved over to d=4
55-
PASS: stride reverse with label propagation succeeded
61+
Solved over to d=4, label="x"
62+
PASS: stride reverse propagated label "x" to over
5663

5764
Test 16: Conv no-padding forward -- label propagated
58-
PASS: conv forward with matching labels succeeded
65+
Solved to d=6, label="x"
66+
PASS: conv forward propagated label "x"
5967

6068
Test 17: Conv no-padding reverse -- label propagated
61-
Solved over to d=4
62-
PASS: conv reverse with label propagation succeeded
69+
Solved over to d=4, label="x"
70+
PASS: conv reverse propagated label "x" to over
6371

64-
Test 18: LUB with conflicting labels -- demotion to d=1
65-
INFO: Shape_error in LUB test: dimension comparison for axis: different labels
66-
NOTE: LUB may raise when axes are mutually constrained
72+
Test 18: LUB with conflicting labels -- strict equality raises
73+
PASS: conflicting labels in mutual inequality correctly raises: dimension comparison for axis: different labels
6774

6875
=== Done ===

0 commit comments

Comments
 (0)