Repository navigation
Drop --> and ..: a pattern is its string, with einsum operands in a List - #63
Merged
Merged
Conversation
… a List Patterns are written as `einops"..."` and the shorthand macros' strings, and a pattern now shows as the string that makes it. The tuple-building operator `-->` and the re-exported `..` go, and with them EllipsisNotation: `...` is a vendored `Ellipsis()`. Commas separate einsum operands, unlike the commas of a Julia tuple: `"i, -> i"` has two, the second 0-dimensional. They now make an internal `List` of operand sides, iterable like the tuple it holds, where before a tuple of tuples meant operands or one array's groups depending on how many arrays came with it. So commas, not arity, decide: `einsum` requires one array per operand, the other operations reject a list, and a pattern without `->` rejects commas. The `parse_shape` fallback for a tuple holding `..` goes too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #63 +/- ##
==========================================
- Coverage 99.49% 99.37% -0.12%
==========================================
Files 15 15
Lines 793 802 +9
==========================================
+ Hits 789 797 +8
- Misses 4 5 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Patterns are now only written as strings,
einops"..."or the shorthand macros' strings. A pattern shows as the string that makes it:-->and..are gone, and with them the EllipsisNotation dependency. Internally...is a vendoredEinops.Ellipsis().Einops.ArrowPattern{L,R}()can still be built from tuples by hand. Theparse_shapefallback that warned about a tuple holding..goes too, since nothing public can make one;parse_shape(x, einops"a b ...")covers it, and tuples of names and-still work.Commas make a
Listof operands. In a pattern, a comma separates einsum operands, unlike the commas of a Julia tuple:"i, -> i"has two operands, the second 0-dimensional. Before, a tuple of tuples meant either operands or one array's groups, depending on how many arrays came with it (#61), so"i, j -> i j"and"(i) (j) -> i j"were the same value. Now commas make an internalList{((:i,), (:j,))}(), which iterates and indexes like the tuple it holds. It is a singleton carrying its operands as a parameter, since an instance holdingSymbols can't be a type parameter.einsumrequires one array per operand: "The pattern has 2 operands, but 1 array was given".->(parse_shape,pack/unpack) reject commas, since nothing takes several of them.einsum(matrix, einops"i, j -> i j")used to read the two operands as one array's axes. It now throws; for one array, write"i j -> i j".Tests: about 190 tuple patterns in the tests were rewritten by a script, which parsed each
-->expression, generated the string, and checked that it reads back to the identical pattern.test/patterns.jl, which tests the parser itself, compares against explicitArrowPattern{L,R}()types. New tests cover the display (every spelling reads back to the same pattern),List's interface and checks, and commas versus arity ineinsum. The full suite passes on Julia 1.10 and 1.13, Zygote on 1.12, and Reactant on 1.13. Doctests and the docs build are clean.🤖 Generated with Claude Code