|
1 | 1 | using Combinatorics: Combinatorics |
2 | | -using NamedDimsArrays: |
3 | | - NamedDimsArrays, |
4 | | - AbstractNamedDimsArray, |
5 | | - AbstractNamedDimsMatrix, |
6 | | - NaiveOrderedSet, |
7 | | - Name, |
8 | | - NameMismatch, |
9 | | - NamedDimsCartesianIndex, |
10 | | - NamedDimsCartesianIndices, |
11 | | - NamedDimsArray, |
12 | | - NamedDimsMatrix, |
13 | | - aligndims, |
14 | | - aligneddims, |
15 | | - apply, |
16 | | - dename, |
17 | | - denamed, |
18 | | - dim, |
19 | | - dimnames, |
20 | | - dims, |
21 | | - fusednames, |
22 | | - isnamed, |
23 | | - mapinds, |
24 | | - name, |
25 | | - named, |
26 | | - nameddims, |
27 | | - inds, |
28 | | - namedoneto, |
29 | | - operator, |
30 | | - product, |
31 | | - replaceinds, |
32 | | - setinds, |
33 | | - state, |
34 | | - unname, |
35 | | - unnamed, |
36 | | - @names |
| 2 | +using NamedDimsArrays: NamedDimsArrays, AbstractNamedDimsArray, AbstractNamedDimsMatrix, |
| 3 | + NaiveOrderedSet, Name, NameMismatch, NamedDimsCartesianIndex, NamedDimsCartesianIndices, |
| 4 | + NamedDimsArray, NamedDimsMatrix, aligndims, aligneddims, apply, dename, denamed, dim, |
| 5 | + dimnames, dims, fusednames, isnamed, mapinds, name, named, nameddims, inds, namedoneto, |
| 6 | + operator, product, replaceinds, setinds, state, unname, unnamed, @names |
37 | 7 | using Test: @test, @test_throws, @testset |
38 | 8 | using VectorInterface: scalartype |
39 | 9 |
|
@@ -74,6 +44,26 @@ const elts = (Float32, Float64, Complex{Float32}, Complex{Float64}) |
74 | 44 | @test dims(na, ("j", "i")) == (2, 1) |
75 | 45 | @test na[1, 1] == a[1, 1] |
76 | 46 |
|
| 47 | + # equals (==)/isequal |
| 48 | + a = randn(elt, 3, 4) |
| 49 | + na = nameddims(a, ("i", "j")) |
| 50 | + @test na == na |
| 51 | + @test na == aligndims(na, ("j", "i")) |
| 52 | + @test isequal(na, na) |
| 53 | + @test isequal(na, aligndims(na, ("j", "i"))) |
| 54 | + @test hash(na) == hash(aligndims(na, ("j", "i"))) |
| 55 | + # Regression test that NamedDimsArrays |
| 56 | + # with different names are not equal (as opposed to |
| 57 | + # erroring). |
| 58 | + @test na ≠ nameddims(a, ("j", "k")) |
| 59 | + @test !isequal(na, nameddims(a, ("j", "k"))) |
| 60 | + @test hash(na) ≠ hash(nameddims(a, ("j", "k"))) |
| 61 | + |
| 62 | + a = randn(elt, 2, 2) |
| 63 | + na = nameddims(a, ("i", "j")) |
| 64 | + @test CartesianIndices(na) == CartesianIndices(a) |
| 65 | + @test collect(pairs(na)) == (CartesianIndices(a) .=> a) |
| 66 | + |
77 | 67 | @test_throws ErrorException NamedDimsArray(randn(4), namedoneto.((2, 2), ("i", "j"))) |
78 | 68 | @test_throws ErrorException NamedDimsArray(randn(2, 2), namedoneto.((2, 3), ("i", "j"))) |
79 | 69 |
|
|
0 commit comments