Skip to content

Commit ff99773

Browse files
Merge pull request JuliaArrays#305 from hyrodium/fix/setindex
Remove unnecessary methods from `setindex`
2 parents 0caea19 + aa937a4 commit ff99773

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

lib/ArrayInterfaceCore/src/ArrayInterfaceCore.jl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -307,16 +307,6 @@ function Base.setindex(x::AbstractArray, v, i...)
307307
return _x
308308
end
309309

310-
function Base.setindex(x::AbstractVector, v, i::Int)
311-
n = length(x)
312-
x .* (i .!== 1:n) .+ v .* (i .== 1:n)
313-
end
314-
315-
function Base.setindex(x::AbstractMatrix, v, i::Int, j::Int)
316-
n, m = Base.size(x)
317-
x .* (i .!== 1:n) .* (j .!== i:m)' .+ v .* (i .== 1:n) .* (j .== i:m)'
318-
end
319-
320310
"""
321311
can_setindex(::Type{T}) -> Bool
322312

lib/ArrayInterfaceCore/test/runtests.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,11 @@ end
234234
@test iszero(x)
235235
@test all(isone, y2)
236236
end
237+
238+
@testset "string" begin
239+
x = fill("a", 2, 3)
240+
@test setindex(x, "b", 2, 1) == setindex(x, "b", CartesianIndex(2, 1)) == ["a" "a" "a";"b" "a" "a"]
241+
end
237242
end
238243

239244
@testset "Sparsity Structure" begin

0 commit comments

Comments
 (0)