Skip to content

Commit

Permalink
Fix size implementation for MockTensor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio Sánchez Ramírez authored and mofeing committed Aug 13, 2024
1 parent 69ebd41 commit 175f538
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions test/struct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ using Reactant
using Test

# from bsc-quantic/Tenet.jl
struct MockTensor{T,N,A<:AbstractArray{T,N}}
struct MockTensor{T,N,A<:AbstractArray{T,N}} <: AbstractArray{T,N}
data::A
inds::Vector{Symbol}
end

MockTensor(data::A, inds) where {T,N,A<:AbstractArray{T,N}} = MockTensor{T,N,A}(data, inds)
Base.parent(t::MockTensor) = t.data
Base.size(t::MockTensor) = size(parent(t))

Base.cos(x::MockTensor) = MockTensor(cos(parent(x)), x.inds)

mutable struct MutableMockTensor{T,N,A<:AbstractArray{T,N}}
mutable struct MutableMockTensor{T,N,A<:AbstractArray{T,N}} <: AbstractArray{T,N}
data::A
inds::Vector{Symbol}
end
Expand All @@ -21,6 +22,7 @@ function MutableMockTensor(data::A, inds) where {T,N,A<:AbstractArray{T,N}}
return MutableMockTensor{T,N,A}(data, inds)
end
Base.parent(t::MutableMockTensor) = t.data
Base.size(t::MutableMockTensor) = size(parent(t))

Base.cos(x::MutableMockTensor) = MutableMockTensor(cos(parent(x)), x.inds)

Expand Down

0 comments on commit 175f538

Please sign in to comment.