Skip to content

Commit

Permalink
Strip the CartesianIndex wrapper from the ind2sub deprecation (#25211)
Browse files Browse the repository at this point in the history
Friendlier ind2sub deprecation messages
  • Loading branch information
timholy authored and JeffBezanson committed May 30, 2018
1 parent 9dc4a94 commit f653b14
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1138,13 +1138,35 @@ workspace() = error("`workspace()` is discontinued, consider Revise.jl for an al
@deprecate_moved unsafe_get "Nullables"

# sub2ind and ind2sub deprecation (PR #24715)
@deprecate ind2sub(A::AbstractArray, ind) CartesianIndices(A)[ind]
@deprecate ind2sub(::Tuple{}, ind::Integer) CartesianIndices()[ind]
@deprecate ind2sub(dims::Tuple{Vararg{Integer,N}} where N, ind::Integer) CartesianIndices(dims)[ind]
@deprecate ind2sub(inds::Tuple{Base.OneTo}, ind::Integer) CartesianIndices(inds)[ind]
@deprecate ind2sub(inds::Tuple{AbstractUnitRange}, ind::Integer) CartesianIndices(inds)[ind]
@deprecate ind2sub(inds::Tuple{Vararg{AbstractUnitRange,N}} where N, ind::Integer) CartesianIndices(inds)[ind]
@deprecate ind2sub(inds::Union{DimsInteger{N},Indices{N}} where N, ind::AbstractVector{<:Integer}) CartesianIndices(inds)[ind]
_ind2sub_depwarn(x, y) = "`ind2sub($x, $y)` is deprecated, use `Tuple(CartesianIndices($x)[$y])` for a direct replacement. In many cases, the conversion to `Tuple` is not necessary."
function ind2sub(A::AbstractArray, ind)
depwarn(_ind2sub_depwarn("A", "ind"), :ind2sub)
Tuple(CartesianIndices(A)[ind])
end
function ind2sub(::Tuple{}, ind::Integer)
depwarn(_ind2sub_depwarn("()", "ind"), :ind2sub)
Tuple(CartesianIndices(())[ind])
end
function ind2sub(dims::Tuple{Vararg{Integer,N}} where N, ind::Integer)
depwarn(_ind2sub_depwarn("dims", "ind"), :ind2sub)
Tuple(CartesianIndices(dims)[ind])
end
function ind2sub(inds::Tuple{Base.OneTo}, ind::Integer)
depwarn(_ind2sub_depwarn("inds", "ind"), :ind2sub)
Tuple(CartesianIndices(inds)[ind])
end
function ind2sub(inds::Tuple{AbstractUnitRange}, ind::Integer)
depwarn(_ind2sub_depwarn("inds", "ind"), :ind2sub)
Tuple(CartesianIndices(inds)[ind])
end
function ind2sub(inds::Tuple{Vararg{AbstractUnitRange,N}} where N, ind::Integer)
depwarn(_ind2sub_depwarn("inds", "ind"), :ind2sub)
Tuple(CartesianIndices(inds)[ind])
end
function ind2sub(inds::Union{DimsInteger{N},Indices{N}} where N, ind::AbstractVector{<:Integer})
depwarn(_ind2sub_depwarn("inds", "ind"), :ind2sub)
Tuple(CartesianIndices(inds)[ind])
end

@deprecate sub2ind(A::AbstractArray, I...) LinearIndices(A)[I...]
@deprecate sub2ind(dims::Tuple{}) LinearIndices(dims)[]
Expand Down

2 comments on commit f653b14

@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.

Something went wrong when running your job:

NanosoldierError: failed to run benchmarks against primary commit: failed process: Process(`sudo cset shield -e su nanosoldier -- -c ./benchscript.sh`, ProcessExited(1)) [1]

Logs and partial data can be found here
cc @ararslan

Please sign in to comment.