Skip to content

Commit c2f0e63

Browse files
Test fixes
1 parent 7156573 commit c2f0e63

4 files changed

Lines changed: 20 additions & 70 deletions

File tree

tests/vibe_see_readme_in_this_dir/test_parsed_values.py

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -433,12 +433,6 @@ def test_I_input_name(self):
433433
i_einsum = self.wl.einsums["I"]
434434
self.assertEqual(i_einsum.input_tensor_names, {"I_in"})
435435

436-
def test_I_inline_renames(self):
437-
"""I einsum string: I(output)[b,m,d] = I_in(input)[b,m,d]"""
438-
i_einsum = self.wl.einsums["I"]
439-
renames_by_name = {r.name: r.source for r in i_einsum.renames}
440-
self.assertEqual(renames_by_name["output"], "I")
441-
self.assertEqual(renames_by_name["input"], "I_in")
442436

443437
def test_I_projection_parsed_as_dict(self):
444438
"""Concise einsum string projections are parsed by _parse_projection, which
@@ -463,31 +457,24 @@ def test_V_output(self):
463457
self.assertEqual(v.output_tensor_names, {"V"})
464458

465459
def test_QK_uses_dict_projection(self):
466-
"""QK: K(weight)[b, M=p, h, e] uses a dict projection for K."""
460+
"""QK: K[b, M:p, h, e] uses a dict projection for K."""
467461
qk = self.wl.einsums["QK"]
468462
k_ta = qk.tensor_accesses["K"]
469-
# M=p is explicit, so it's not an ImpliedProjection
463+
# M:p is explicit, so it's not an ImpliedProjection
470464
self.assertNotIsInstance(k_ta.projection, ImpliedProjection)
471465
self.assertEqual(k_ta.projection["M"], "p")
472466

473467
def test_QK_Q_projection_is_dict(self):
474-
"""Q(input)[b, m, h, e] -- from a concise string, parsed as a plain dict."""
468+
"""Q[b, m, h, e] -- from a concise string, parsed as a plain dict."""
475469
qk = self.wl.einsums["QK"]
476470
q_ta = qk.tensor_accesses["Q"]
477471
self.assertNotIsInstance(q_ta.projection, ImpliedProjection)
478472
self.assertEqual(
479473
dict(q_ta.projection), {"B": "b", "M": "m", "H": "h", "E": "e"}
480474
)
481475

482-
def test_QK_inline_renames(self):
483-
"""QK: Q(input), K(weight) -> renames: {input: Q, weight: K}"""
484-
qk = self.wl.einsums["QK"]
485-
renames_by_name = {r.name: r.source for r in qk.renames}
486-
self.assertEqual(renames_by_name["input"], "Q")
487-
self.assertEqual(renames_by_name["weight"], "K")
488-
489476
def test_AV_dict_projection_V(self):
490-
"""AV: V(weight)[b, M=p, H=h, E=f]"""
477+
"""AV: V[b, M:p, H:h, E:f]"""
491478
av = self.wl.einsums["AV"]
492479
v_ta = av.tensor_accesses["V"]
493480
self.assertNotIsInstance(v_ta.projection, ImpliedProjection)

tests/vibe_see_readme_in_this_dir/test_workload_parser.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def test_simple_einsum_list_projection(self):
4242
self.assertTrue(output["output"])
4343

4444
def test_einsum_with_dict_projection(self):
45-
einsum_str = "QK[b, m, p, h] = Q[b, m, h, e] * K[B=b, M=p, H=h, E=e]"
45+
einsum_str = "QK[b, m, p, h] = Q[b, m, h, e] * K[B:b, M:p, H:h, E:e]"
4646
result = _parse_einsum_string(einsum_str)
4747

4848
self.assertEqual(result["name"], "QK")
@@ -56,7 +56,7 @@ def test_einsum_with_dict_projection(self):
5656

5757
def test_einsum_with_mixed_projection(self):
5858
"""Test parsing einsum with mixed-style projection using equals."""
59-
einsum_str = "QK[b, m, p, h] = Q[b, m, h, e] * K[b, M=p, h, e]"
59+
einsum_str = "QK[b, m, p, h] = Q[b, m, h, e] * K[b, M:p, h, e]"
6060
result = _parse_einsum_string(einsum_str)
6161

6262
# Check the K tensor with mixed projection
@@ -86,13 +86,13 @@ def test_einsum_malformed_no_equals(self):
8686
"""Test that parsing fails when there's no equals sign."""
8787
with self.assertRaises(ValueError) as ctx:
8888
_parse_einsum_string("V[b, m, h, e]")
89-
self.assertIn("Invalid einsum format:", str(ctx.exception))
89+
self.assertIn("Invalid einsum format", str(ctx.exception))
9090

9191
def test_einsum_malformed_no_brackets(self):
9292
"""Test that parsing fails when brackets are missing."""
9393
with self.assertRaises(ValueError) as ctx:
9494
_parse_einsum_string("V = I * WV")
95-
self.assertIn("Invalid einsum format:", str(ctx.exception))
95+
self.assertIn("Invalid einsum format", str(ctx.exception))
9696

9797
def test_einsum_malformed_empty_projection(self):
9898
"""Test that parsing fails with empty projection."""
@@ -138,7 +138,7 @@ def test_einsum_empty_tensor_name(self):
138138
"""Test that empty tensor names raise an error."""
139139
with self.assertRaises(ValueError) as ctx:
140140
_parse_einsum_string("[b, m] = I[b] * W[m]")
141-
self.assertIn("Invalid einsum format:", str(ctx.exception))
141+
self.assertIn("Invalid einsum format", str(ctx.exception))
142142

143143
def test_projection_invalid_identifier(self):
144144
with self.assertRaises(ValueError):
@@ -313,7 +313,7 @@ def test_very_long_tensor_name(self):
313313

314314
def test_projection_equals_without_space(self):
315315
"""Test mixed projection with no spaces around equals."""
316-
result = _parse_einsum_string("V[b] = I[B=b]")
316+
result = _parse_einsum_string("V[b] = I[B:b]")
317317
self.assertEqual(result["tensor_accesses"][0]["projection"], {"B": "b"})
318318

319319
def test_multiple_asterisks(self):
@@ -341,13 +341,11 @@ def test_parse_string_entry(self):
341341

342342
def test_parse_dict_entry_with_einsum_key(self):
343343
entry = {
344-
"einsum": "QK[b, m, p, h] = Q[b, m, h, e] * K[b, M=p, h, e]",
345-
"renames": {"weight": "K", "input": "Q"},
344+
"einsum": "QK[b, m, p, h] = Q[b, m, h, e] * K[b, M:p, h, e]",
346345
}
347346
result = _parse_einsum_entry(entry)
348347

349348
self.assertEqual(result["name"], "QK")
350-
self.assertEqual(result["renames"], {"weight": "K", "input": "Q"})
351349

352350
def test_parse_dict_entry_full_format(self):
353351
entry = {

tests/vibe_see_readme_in_this_dir/test_workload_parsing.py

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,19 @@ def test_simple_identifiers_become_dict(self):
3333
self.assertEqual(result, {"A": "a", "B": "b", "C": "c"})
3434

3535
def test_explicit_equals_projection(self):
36-
result = _parse_projection("B=b, M=p, H=h, E=e")
36+
result = _parse_projection("B:b, M:p, H:h, E:e")
3737
self.assertEqual(result, {"B": "b", "M": "p", "H": "h", "E": "e"})
3838

3939
def test_mixed_implicit_and_explicit(self):
40-
result = _parse_projection("b, M=p, h, e")
40+
result = _parse_projection("b, M:p, h, e")
4141
self.assertEqual(result, {"B": "b", "M": "p", "H": "h", "E": "e"})
4242

4343
def test_single_element(self):
4444
result = _parse_projection("x")
4545
self.assertEqual(result, {"X": "x"})
4646

4747
def test_single_explicit(self):
48-
result = _parse_projection("X=y")
48+
result = _parse_projection("X:y")
4949
self.assertEqual(result, {"X": "y"})
5050

5151
def test_empty_raises_value_error(self):
@@ -193,7 +193,7 @@ def test_single_input_tensor(self):
193193

194194
def test_dict_projection(self):
195195
result = _parse_einsum_string(
196-
"QK[b, m, p, h] = Q[b, m, h, e] * K[B=b, M=p, H=h, E=e]"
196+
"QK[b, m, p, h] = Q[b, m, h, e] * K[B:b, M:p, H:h, E:e]"
197197
)
198198
k_tensor = result["tensor_accesses"][1]
199199
self.assertEqual(k_tensor["name"], "K")
@@ -203,20 +203,12 @@ def test_dict_projection(self):
203203

204204
def test_mixed_projection(self):
205205
result = _parse_einsum_string(
206-
"QK[b, m, p, h] = Q[b, m, h, e] * K[b, M=p, h, e]"
206+
"QK[b, m, p, h] = Q[b, m, h, e] * K[b, M:p, h, e]"
207207
)
208208
k_tensor = result["tensor_accesses"][1]
209209
expected = {"B": "b", "M": "p", "H": "h", "E": "e"}
210210
self.assertEqual(k_tensor["projection"], expected)
211211

212-
def test_with_renames_alias(self):
213-
result = _parse_einsum_string(
214-
"QK(output)[b, m, p, h] = Q(input)[b, m, h, e] * K(weight)[b, M=p, h, e]"
215-
)
216-
self.assertEqual(result["name"], "QK")
217-
self.assertEqual(
218-
result["renames"], {"output": "QK", "input": "Q", "weight": "K"}
219-
)
220212

221213
def test_copy_operation(self):
222214
result = _parse_einsum_string("I[b, m, d] = I_in[b, m, d]")
@@ -300,7 +292,7 @@ def test_entry_with_einsum_key(self):
300292

301293
def test_entry_with_einsum_and_renames(self):
302294
entry = {
303-
"einsum": "QK[b, m, p, h] = Q[b, m, h, e] * K[b, M=p, h, e]",
295+
"einsum": "QK[b, m, p, h] = Q[b, m, h, e] * K[b, M:p, h, e]",
304296
"renames": {"weight": "K", "input": "Q"},
305297
}
306298
result = _parse_einsum_entry(entry)
@@ -375,16 +367,6 @@ def test_invalid_tensor_accesses_type_raises(self):
375367
with self.assertRaises(ValueError):
376368
_parse_einsum_entry(entry)
377369

378-
def test_rename_already_in_einsum_string_raises(self):
379-
"""If the einsum string defines a rename alias and we try to add the same."""
380-
entry = {
381-
"einsum": "QK(output)[b] = Q(input)[b]",
382-
"renames": {"output": "QK"}, # output is already set by alias
383-
}
384-
with self.assertRaises(ValueError) as ctx:
385-
_parse_einsum_entry(entry)
386-
self.assertIn("already exists", str(ctx.exception))
387-
388370

389371
if __name__ == "__main__":
390372
unittest.main()

tests/vibe_see_readme_in_this_dir/test_yaml_and_expressions.py

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -490,14 +490,6 @@ def test_einsum_keyword_preserves_tensor_accesses(self):
490490
names = {ta["name"] for ta in parsed["tensor_accesses"]}
491491
self.assertEqual(names, {"A", "B", "C"})
492492

493-
def test_einsum_keyword_with_extra_renames(self):
494-
entry = {
495-
"einsum": "C[m, n] = A[m, k] * B[k, n]",
496-
"renames": {"weight": "B"},
497-
}
498-
parsed = _parse_einsum_entry(entry)
499-
self.assertEqual(parsed["renames"]["weight"], "B")
500-
501493
def test_conflicting_tensor_access_attr_raises(self):
502494
"""Setting projection in both einsum string and tensor_accesses is an error."""
503495
entry = {
@@ -515,15 +507,6 @@ def test_nonexistent_tensor_in_extras_raises(self):
515507
with self.assertRaises(ValueError):
516508
_parse_einsum_entry(entry)
517509

518-
def test_duplicate_rename_raises(self):
519-
"""If the einsum string already defines a rename, adding the same raises."""
520-
entry = {
521-
"einsum": "C(output)[m, n] = A[m, k] * B[k, n]",
522-
"renames": {"output": "C"},
523-
}
524-
with self.assertRaises(ValueError):
525-
_parse_einsum_entry(entry)
526-
527510
def test_is_copy_operation_not_forwarded(self):
528511
"""Extra keys like is_copy_operation are NOT forwarded by _parse_einsum_entry."""
529512
entry = {
@@ -929,8 +912,8 @@ class TestParseProjectionDocExamples(unittest.TestCase):
929912
"""Test _parse_projection for cases shown in the docs."""
930913

931914
def test_mixed_implicit_and_explicit(self):
932-
"""Parsing 'b, M=p, h, e' yields a dict with mixed implicit/explicit."""
933-
result = _parse_projection("b, M=p, h, e")
915+
"""Parsing 'b, M:p, h, e' yields a dict with mixed implicit/explicit."""
916+
result = _parse_projection("b, M:p, h, e")
934917
self.assertEqual(result["B"], "b")
935918
self.assertEqual(result["M"], "p")
936919
self.assertEqual(result["H"], "h")
@@ -941,7 +924,7 @@ def test_all_implicit(self):
941924
self.assertEqual(result, {"M": "m", "K": "k", "N": "n"})
942925

943926
def test_all_explicit(self):
944-
result = _parse_projection("Row=m, Col=n")
927+
result = _parse_projection("Row:m, Col:n")
945928
self.assertEqual(result, {"Row": "m", "Col": "n"})
946929

947930

0 commit comments

Comments
 (0)