Skip to content

Commit

Permalink
Move scalar broadcast setindex_shape_check method to deprecated (#26967)
Browse files Browse the repository at this point in the history
* Remove unnecessary setindex_shape_check method

* Ensure deprecation still works and fixup tests
  • Loading branch information
mbauman authored May 7, 2018
1 parent 0c28685 commit 1feb505
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1496,6 +1496,7 @@ end
# PR #26347: Deprecate implicit scalar broadcasting in setindex!
_axes(::Ref) = ()
_axes(x) = axes(x)
setindex_shape_check(X::Base.Iterators.Repeated, I...) = nothing
function deprecate_scalar_setindex_broadcast_message(v, I...)
value = (_axes(Base.Broadcast.broadcastable(v)) == () ? "x" : "(x,)")
"using `A[I...] = x` to implicitly broadcast `x` across many locations is deprecated. Use `A[I...] .= $value` instead."
Expand Down
1 change: 0 additions & 1 deletion base/indices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ function setindex_shape_check(X::AbstractArray{<:Any,2}, i::Integer, j::Integer)
throw_setindex_mismatch(X, (i,j))
end
end
setindex_shape_check(X, I...) = nothing # Non-arrays broadcast to all idxs

# convert to a supported index type (array or Int)
"""
Expand Down
4 changes: 2 additions & 2 deletions test/arrayops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,8 @@ end
@test findall(in([1, 2]), 2) == [1]
@test findall(in([1, 2]), 3) == []

rt = Base.return_types(setindex!, Tuple{Array{Int32, 3}, UInt8, Vector{Int}, Int16, UnitRange{Int}})
@test length(rt) == 1 && rt[1] == Array{Int32, 3}
rt = Base.return_types(setindex!, Tuple{Array{Int32, 3}, Vector{UInt8}, Vector{Int}, Int16, UnitRange{Int}})
@test length(rt) == 1 && rt[1] === Array{Int32, 3}
end
@testset "construction" begin
@test typeof(Vector{Int}(undef, 3)) == Vector{Int}
Expand Down

2 comments on commit 1feb505

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

Please sign in to comment.