Skip to content

Commit

Permalink
make assignment work on ustrip'ed StridedArrays
Browse files Browse the repository at this point in the history
  • Loading branch information
bjarthur committed Apr 18, 2023
1 parent 4ce89e1 commit 41f6b78
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 41f6b78

Please sign in to comment.