Repository navigation
Add equals_layout hook for == on LayoutArrays - #284
Merged
Merged
Conversation
`==` with a LayoutArray (or a view of one) on either side now reduces to `equals_layout(MemoryLayout(A), MemoryLayout(B), A, B)`, which can be overloaded per layout. The default falls back to the generic AbstractArray implementation in Base, so behaviour is unchanged unless a layout opts in. Also resolves the resulting ambiguities with SparseArrays.ReadOnly in the SparseArrays extension. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #284 +/- ##
==========================================
+ Coverage 90.26% 90.33% +0.06%
==========================================
Files 12 12
Lines 1973 1987 +14
==========================================
+ Hits 1781 1795 +14
Misses 192 192 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Adds a layout hook for equality, alongside
mapreduce_layoutandcopyto!_layout:==routes through the hook whenever either argument is aLayoutArrayor a view of one. The default falls back to Base's genericAbstractArraycomparison, so behaviour doesn't change unless a layout opts in. Layouts can then specialise equality, for example to compare structured data directly rather than entry by entry.Notes
SubArrayoverloads don't constrain the dimension, so comparing views of different dimensions isn't ambiguous.SparseArrays.ReadOnly's==.ArrayLayoutsSparseArraysExtadds resolving methods, guarded byisdefined(SparseArrays, :ReadOnly).Test.detect_ambiguitiesover ArrayLayouts, Base, LinearAlgebra, FillArrays and SparseArrays reports no==ambiguities.==(::AbstractArray, ::SomeType)or its mirror may see new ambiguities when one side is aLayoutArray.Tests
A new
==testset intest/test_layoutarray.jlcovers comparisons in both directions between layout arrays, plain arrays and views. It also includes size mismatches and a custom layout that overloadsequals_layout. The full test suite passes locally.🤖 Generated with Claude Code