From 41f6b786a802f4cb917e85b9e5ac94911b18508a 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 StridedArrays --- src/utils.jl | 2 +- test/runtests.jl | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils.jl b/src/utils.jl index c0975ce5..c07f9daa 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::StridedArray{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..fee18b7f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1425,6 +1425,10 @@ end Tridiagonal{Int} @test typeof(ustrip(SymTridiagonal([1,2,3]u"m", [4,5]u"m"))) <: SymTridiagonal{Int} + A = zeros(3,3)*1u"s" + V = view(A,2:3,2:3) + ustrip(V)[1,1]=1 + @test A[2,2] == 1u"s" end @testset ">> Linear algebra" begin @test istril(1m) === true