From 25ba82336e8a94ca755378b3173a2a658ff7a330 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Wed, 3 Jul 2024 13:17:03 +0200 Subject: [PATCH] Add tests --- src/sparse_coeffs.jl | 6 ++---- test/caching_allocations.jl | 4 ++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/sparse_coeffs.jl b/src/sparse_coeffs.jl index 152dbe5..3e7236f 100644 --- a/src/sparse_coeffs.jl +++ b/src/sparse_coeffs.jl @@ -57,7 +57,6 @@ Base.broadcastable(sc::SparseCoefficients) = sc Base.BroadcastStyle(::Type{<:SparseCoefficients{K}}) where {K} = BroadcastStyle{K}() # Disallow mixing broadcasts. function Base.BroadcastStyle(::BroadcastStyle, ::Base.BroadcastStyle) - @show @__LINE__ return throw( ArgumentError( "Cannot broadcast `StarAlgebras.SparseCoefficients` with" * @@ -68,7 +67,6 @@ end # Allow broadcasting over scalars. function Base.BroadcastStyle(style::BroadcastStyle, ::Base.Broadcast.DefaultArrayStyle{0}) - @show @__LINE__ return style end @@ -79,8 +77,8 @@ Base.axes(sc::SparseCoefficients) = (sc.basis_elements,) # `_get_arg` and `getindex` are inspired from `JuMP.Containers.SparseAxisArray` _getindex(x::SparseCoefficients, index) = getindex(x, index) -_getindex(x::Any, ::Any) = (@show @__LINE__; x) -_getindex(x::Ref, ::Any) = (@show @__LINE__; x[]) +_getindex(x::Any, ::Any) = x +_getindex(x::Ref, ::Any) = x[] function _get_arg(args::Tuple, index) return (_getindex(first(args), index), _get_arg(Base.tail(args), index)...) diff --git a/test/caching_allocations.jl b/test/caching_allocations.jl index 0003304..862ec22 100644 --- a/test/caching_allocations.jl +++ b/test/caching_allocations.jl @@ -107,5 +107,9 @@ end @test c .* 2 == res @test c .+ 1 == res @test 1 .+ c == res + @test MA.Zero() .+ c == c + @test c .+ MA.Zero() == c + err = ArgumentError("Cannot broadcast `StarAlgebras.SparseCoefficients` with another array of different type") + @test_throws err c .+ ones(3) end end