From 6609979782cb8d6c4dd27b0bfcbfe427d3ffdccb Mon Sep 17 00:00:00 2001 From: Ben Arthur Date: Fri, 14 Apr 2023 17:35:33 -0400 Subject: [PATCH] make assignment work on ustrip'ed AbstractArrays --- src/utils.jl | 2 +- test/runtests.jl | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/utils.jl b/src/utils.jl index c0975ce5..cc8baef2 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -75,7 +75,7 @@ julia> a[1] = 3u"m"; b 2 ``` """ -@inline ustrip(A::Array{Q}) where {Q <: Quantity} = reinterpret(numtype(Q), A) +@inline ustrip(A::AbstractArray{Q}) where {Q <: Quantity} = reinterpret(numtype(Q), A) @deprecate(ustrip(A::AbstractArray{T}) where {T<:Number}, ustrip.(A)) diff --git a/test/runtests.jl b/test/runtests.jl index f0f09bd7..e666a700 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1425,6 +1425,9 @@ end Tridiagonal{Int} @test typeof(ustrip(SymTridiagonal([1,2,3]u"m", [4,5]u"m"))) <: SymTridiagonal{Int} + S = Symmetric(zeros(3,3))*1u"s" + ustrip(S)[1]=1 + @test S[1] == 1u"s" end @testset ">> Linear algebra" begin @test istril(1m) === true