Skip to content

Commit d513fee

Browse files
committed
Move weak tensor equality method to TestUtils.jl
1 parent b5f8370 commit d513fee

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/ricci.jl

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,6 @@ import LinearAlgebra
66

77
abstract type Tensor end
88

9-
# Shortcut for simpler comparison from
10-
# https://stackoverflow.com/questions/62336686/struct-equality-with-arrays
11-
function Base.:(==)(a::T, b::T) where {T<:Tensor}
12-
f = fieldnames(T)
13-
14-
return (getfield.(Ref(a), f) == getfield.(Ref(b), f)) ||
15-
(reverse(getfield.(Ref(a), f)) == getfield.(Ref(b), f))
16-
end
17-
189
Value = Union{Tensor,Real}
1910

2011
function get_indices(arg::Real)

test/TestUtils.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ using DiffMatic: Variable, KrD, Zero
88
using DiffMatic: BinaryOperation, UnaryOperation
99
using DiffMatic: IndexList
1010

11+
# Shortcut for simpler comparison from
12+
# https://stackoverflow.com/questions/62336686/struct-equality-with-arrays
13+
function Base.:(==)(a::T, b::T) where {T<:DiffMatic.Tensor}
14+
f = fieldnames(T)
15+
16+
return (getfield.(Ref(a), f) == getfield.(Ref(b), f)) ||
17+
(reverse(getfield.(Ref(a), f)) == getfield.(Ref(b), f))
18+
end
19+
1120
function can_remap(left::IndexList, right::IndexList)
1221
lu = unique(left)
1322
ru = unique(right)

0 commit comments

Comments
 (0)