From 175f5380667654f5e5367e2db42a036790a2acbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Mon, 22 Jul 2024 19:38:37 +0200 Subject: [PATCH] Fix `size` implementation for `MockTensor` tests --- test/struct.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/struct.jl b/test/struct.jl index c03357e6d..f4ba1fd48 100644 --- a/test/struct.jl +++ b/test/struct.jl @@ -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 @@ -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)