Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/abstractsparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,13 @@ else
end
end

macro allowscalar(p)
quote
$(allowscalar)($(esc(p)))
@Core.latestworld
end
end

@inline _is_fixed(::AbstractArray) = false
@inline _is_fixed(A::AbstractArray, Bs::Vararg{Any,N}) where N = _is_fixed(A) || (N > 0 && _is_fixed(Bs...))
macro if_move_fixed(a...)
Expand Down
8 changes: 4 additions & 4 deletions test/allowscalar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ using Test, SparseArrays
A = sprandn(10, 20, 0.9)
A[1, 1] = 2
@test A[1, 1] == 2
SparseArrays.allowscalar(false)
SparseArrays.@allowscalar(false)
@test_throws Any A[1, 1]
@test_throws Any A[1, 1] = 2
SparseArrays.allowscalar(true)
SparseArrays.@allowscalar(true)
@test A[1, 1] == 2
A[1, 1] = 3
@test A[1, 1] == 3

B = sprandn(10, 0.9)
B[1] = 2
@test B[1] == 2
SparseArrays.allowscalar(false)
SparseArrays.@allowscalar(false)
@test_throws Any B[1]
SparseArrays.allowscalar(true)
SparseArrays.@allowscalar(true)
@test B[1] == 2
B[1] = 3
@test B[1] == 3
Expand Down
Loading