Skip to content

Commit

Permalink
Replace all use of 'indexes' with 'indices'
Browse files Browse the repository at this point in the history
  • Loading branch information
ararslan committed Dec 15, 2017
1 parent 9315ca0 commit 2a776d2
Show file tree
Hide file tree
Showing 37 changed files with 195 additions and 186 deletions.
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,10 @@ Deprecated or removed
* The aliases `Complex32`, `Complex64` and `Complex128` have been deprecated in favor of `ComplexF16`,
`ComplexF32` and `ComplexF64` respectively ([#24647]).

* `Base.parentindexes` and `SharedArrays.localindexes` have been renamed to `parentindices`
and `localindices`, respectively. Similarly, the `indexes` field in the `SubArray` type
has been renamed to `indices` without deprecation ([#25088]).

* `Associative` has been deprecated in favor of `AbstractDict` ([#25012]).

Command-line option changes
Expand Down Expand Up @@ -1756,3 +1760,4 @@ Command-line option changes
[#24653]: https://github.com/JuliaLang/julia/issues/24653
[#24869]: https://github.com/JuliaLang/julia/issues/24869
[#25021]: https://github.com/JuliaLang/julia/issues/25021
[#25088]: https://github.com/JuliaLang/julia/issues/25088
10 changes: 5 additions & 5 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1876,22 +1876,22 @@ function mapslices(f, A::AbstractArray, dims::AbstractVector)
R[ridx...] = r1

nidx = length(otherdims)
indexes = Iterators.drop(CartesianRange(itershape), 1)
inner_mapslices!(safe_for_reuse, indexes, nidx, idx, otherdims, ridx, Aslice, A, f, R)
indices = Iterators.drop(CartesianRange(itershape), 1)
inner_mapslices!(safe_for_reuse, indices, nidx, idx, otherdims, ridx, Aslice, A, f, R)
end

@noinline function inner_mapslices!(safe_for_reuse, indexes, nidx, idx, otherdims, ridx, Aslice, A, f, R)
@noinline function inner_mapslices!(safe_for_reuse, indices, nidx, idx, otherdims, ridx, Aslice, A, f, R)
if safe_for_reuse
# when f returns an array, R[ridx...] = f(Aslice) line copies elements,
# so we can reuse Aslice
for I in indexes # skip the first element, we already handled it
for I in indices # skip the first element, we already handled it
replace_tuples!(nidx, idx, ridx, otherdims, I)
_unsafe_getindex!(Aslice, A, idx...)
R[ridx...] = f(Aslice)
end
else
# we can't guarantee safety (#18524), so allocate new storage for each slice
for I in indexes
for I in indices
replace_tuples!(nidx, idx, ridx, otherdims, I)
R[ridx...] = f(A[idx...])
end
Expand Down
8 changes: 4 additions & 4 deletions base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1683,7 +1683,7 @@ findlast(testf::Function, A) = findprev(testf, A, endof(A))
"""
find(f::Function, A)
Return a vector `I` of the linear indexes of `A` where `f(A[I])` returns `true`.
Return a vector `I` of the linear indices of `A` where `f(A[I])` returns `true`.
If there are no such elements of `A`, return an empty array.
# Examples
Expand All @@ -1710,7 +1710,7 @@ julia> find(isodd, [2, 4])
```
"""
function find(testf::Function, A)
# use a dynamic-length array to store the indexes, then copy to a non-padded
# use a dynamic-length array to store the indices, then copy to a non-padded
# array for the return
tmpI = Vector{Int}()
inds = _index_remapper(A)
Expand Down Expand Up @@ -1775,7 +1775,7 @@ findn(A::AbstractVector) = find(A)
"""
findn(A)
Return a vector of indexes for each dimension giving the locations of the non-zeros in `A`
Return a vector of indices for each dimension giving the locations of the non-zeros in `A`
(determined by `A[i]!=0`).
If there are no non-zero elements of `A`, return a 2-tuple of empty arrays.
Expand Down Expand Up @@ -1817,7 +1817,7 @@ end
"""
findnz(A)
Return a tuple `(I, J, V)` where `I` and `J` are the row and column indexes of the non-zero
Return a tuple `(I, J, V)` where `I` and `J` are the row and column indices of the non-zero
values in matrix `A`, and `V` is a vector of the non-zero values.
# Examples
Expand Down
2 changes: 1 addition & 1 deletion base/asyncmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ function start(itr::AsyncCollector)
itr.batch_size = verify_batch_size(itr.batch_size)
if itr.batch_size !== nothing
exec_func = batch -> begin
# extract indexes from the input tuple
# extract indices from the input tuple
batch_idxs = map(x->x[1], batch)

# and the args tuple....
Expand Down
2 changes: 1 addition & 1 deletion base/bitarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,7 @@ end

function reverse!(B::BitVector)
# Basic idea: each chunk is divided into two blocks of size k = n % 64, and
# h = 64 - k. Walk from either end (with indexes i and j) reversing chunks
# h = 64 - k. Walk from either end (with indices i and j) reversing chunks
# and separately ORing their two blocks into place.
#
# chunk 3 chunk 2 chunk 1
Expand Down
5 changes: 4 additions & 1 deletion base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ function convert(::Type{UpperTriangular}, A::Bidiagonal)
end

# Deprecate three-arg SubArray since the constructor doesn't need the dims tuple
@deprecate SubArray(parent::AbstractArray, indexes::Tuple, dims::Tuple) SubArray(parent, indexes)
@deprecate SubArray(parent::AbstractArray, indices::Tuple, dims::Tuple) SubArray(parent, indices)

# Deprecate vectorized unary functions over sparse matrices in favor of compact broadcast syntax (#17265).
for f in (:sind, :asind, :tand, :atand, :sinpi, :cosc, :ceil, :floor, :trunc,
Expand Down Expand Up @@ -3254,6 +3254,9 @@ end
@deprecate indices(a) axes(a)
@deprecate indices(a, d) axes(a, d)

# Issue #12902
@deprecate parentindexes parentindices

# END 0.7 deprecations

# BEGIN 1.0 deprecations
Expand Down
2 changes: 1 addition & 1 deletion base/dict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ mutable struct Dict{K,V} <: AbstractDict{K,V}
ndel::Int
count::Int
age::UInt
idxfloor::Int # an index <= the indexes of all used slots
idxfloor::Int # an index <= the indices of all used slots
maxprobe::Int

function Dict{K,V}() where V where K
Expand Down
2 changes: 1 addition & 1 deletion base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ export
nonzeros,
ones,
parent,
parentindexes,
parentindices,
partialsort,
partialsort!,
partialsortperm,
Expand Down
4 changes: 2 additions & 2 deletions base/intfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ bitstring(x::Union{Int128,UInt128}) = bin(reinterpret(UInt128,x),128)
Return an array with element type `T` (default `Int`) of the digits of `n` in the given
base, optionally padded with zeros to a specified size. More significant digits are at
higher indexes, such that `n == sum([digits[k]*base^(k-1) for k=1:length(digits)])`.
higher indices, such that `n == sum([digits[k]*base^(k-1) for k=1:length(digits)])`.
# Examples
```jldoctest
Expand Down Expand Up @@ -796,7 +796,7 @@ hastypemax(::Type{T}) where {T} = applicable(typemax, T)
digits!(array, n::Integer, base::Integer=10)
Fills an array of the digits of `n` in the given base. More significant digits are at higher
indexes. If the array length is insufficient, the least significant digits are filled up to
indices. If the array length is insufficient, the least significant digits are filled up to
the array length. If the array length is excessive, the excess portion is filled with zeros.
# Examples
Expand Down
2 changes: 1 addition & 1 deletion base/multidimensional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ index_lengths() = ()
@inline index_lengths(A::AbstractArray, rest...) = (length(A), index_lengths(rest...)...)
@inline index_lengths(A::Slice, rest...) = (length(indices1(A)), index_lengths(rest...)...)

# shape of array to create for getindex() with indexes I, dropping scalars
# shape of array to create for getindex() with indices I, dropping scalars
# returns a Tuple{Vararg{AbstractUnitRange}} of indices
index_shape() = ()
@inline index_shape(::Real, rest...) = index_shape(rest...)
Expand Down
24 changes: 12 additions & 12 deletions base/reshapedarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ size(A::ReshapedArray) = A.dims
similar(A::ReshapedArray, eltype::Type, dims::Dims) = similar(parent(A), eltype, dims)
IndexStyle(::Type{<:ReshapedArrayLF}) = IndexLinear()
parent(A::ReshapedArray) = A.parent
parentindexes(A::ReshapedArray) = map(s->1:s, size(parent(A)))
parentindices(A::ReshapedArray) = map(s->1:s, size(parent(A)))
reinterpret(::Type{T}, A::ReshapedArray, dims::Dims) where {T} = reinterpret(T, parent(A), dims)

@inline ind2sub_rs(::Tuple{}, i::Int) = i
Expand All @@ -193,18 +193,18 @@ end
@inbounds ret = parent(A)[index]
ret
end
@inline function getindex(A::ReshapedArray{T,N}, indexes::Vararg{Int,N}) where {T,N}
@boundscheck checkbounds(A, indexes...)
_unsafe_getindex(A, indexes...)
@inline function getindex(A::ReshapedArray{T,N}, indices::Vararg{Int,N}) where {T,N}
@boundscheck checkbounds(A, indices...)
_unsafe_getindex(A, indices...)
end
@inline function getindex(A::ReshapedArray, index::ReshapedIndex)
@boundscheck checkbounds(parent(A), index.parentindex)
@inbounds ret = parent(A)[index.parentindex]
ret
end

@inline function _unsafe_getindex(A::ReshapedArray{T,N}, indexes::Vararg{Int,N}) where {T,N}
i = sub2ind(size(A), indexes...)
@inline function _unsafe_getindex(A::ReshapedArray{T,N}, indices::Vararg{Int,N}) where {T,N}
i = sub2ind(size(A), indices...)
I = ind2sub_rs(A.mi, i)
_unsafe_getindex_rs(parent(A), I)
end
Expand All @@ -216,25 +216,25 @@ _unsafe_getindex_rs(A, i::Integer) = (@inbounds ret = A[i]; ret)
@inbounds parent(A)[index] = val
val
end
@inline function setindex!(A::ReshapedArray{T,N}, val, indexes::Vararg{Int,N}) where {T,N}
@boundscheck checkbounds(A, indexes...)
_unsafe_setindex!(A, val, indexes...)
@inline function setindex!(A::ReshapedArray{T,N}, val, indices::Vararg{Int,N}) where {T,N}
@boundscheck checkbounds(A, indices...)
_unsafe_setindex!(A, val, indices...)
end
@inline function setindex!(A::ReshapedArray, val, index::ReshapedIndex)
@boundscheck checkbounds(parent(A), index.parentindex)
@inbounds parent(A)[index.parentindex] = val
val
end

@inline function _unsafe_setindex!(A::ReshapedArray{T,N}, val, indexes::Vararg{Int,N}) where {T,N}
@inbounds parent(A)[ind2sub_rs(A.mi, sub2ind(size(A), indexes...))...] = val
@inline function _unsafe_setindex!(A::ReshapedArray{T,N}, val, indices::Vararg{Int,N}) where {T,N}
@inbounds parent(A)[ind2sub_rs(A.mi, sub2ind(size(A), indices...))...] = val
val
end

# helpful error message for a common failure case
const ReshapedRange{T,N,A<:AbstractRange} = ReshapedArray{T,N,A,Tuple{}}
setindex!(A::ReshapedRange, val, index::Int) = _rs_setindex!_err()
setindex!(A::ReshapedRange{T,N}, val, indexes::Vararg{Int,N}) where {T,N} = _rs_setindex!_err()
setindex!(A::ReshapedRange{T,N}, val, indices::Vararg{Int,N}) where {T,N} = _rs_setindex!_err()
setindex!(A::ReshapedRange, val, index::ReshapedIndex) = _rs_setindex!_err()

@noinline _rs_setindex!_err() = error("indexed assignment fails for a reshaped range; consider calling collect")
Expand Down
12 changes: 6 additions & 6 deletions base/serialize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -274,16 +274,16 @@ end
function trimmedsubarray(V::SubArray{T,N,A}) where {T,N,A<:Array}
dest = Array{eltype(V)}(uninitialized, trimmedsize(V))
copy!(dest, V)
_trimmedsubarray(dest, V, (), V.indexes...)
_trimmedsubarray(dest, V, (), V.indices...)
end

trimmedsize(V) = index_lengths(V.indexes...)
trimmedsize(V) = index_lengths(V.indices...)

function _trimmedsubarray(A, V::SubArray{T,N,P,I,LD}, newindexes) where {T,N,P,I,LD}
LD && return SubArray{T,N,P,I,LD}(A, newindexes, Base.compute_offset1(A, 1, newindexes), 1)
SubArray{T,N,P,I,LD}(A, newindexes, 0, 0)
function _trimmedsubarray(A, V::SubArray{T,N,P,I,LD}, newindices) where {T,N,P,I,LD}
LD && return SubArray{T,N,P,I,LD}(A, newindices, Base.compute_offset1(A, 1, newindices), 1)
SubArray{T,N,P,I,LD}(A, newindices, 0, 0)
end
_trimmedsubarray(A, V, newindexes, index::ViewIndex, indexes...) = _trimmedsubarray(A, V, (newindexes..., trimmedindex(V.parent, length(newindexes)+1, index)), indexes...)
_trimmedsubarray(A, V, newindices, index::ViewIndex, indices...) = _trimmedsubarray(A, V, (newindices..., trimmedindex(V.parent, length(newindices)+1, index)), indices...)

trimmedindex(P, d, i::Real) = oftype(i, 1)
trimmedindex(P, d, i::Colon) = i
Expand Down
4 changes: 2 additions & 2 deletions base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1700,7 +1700,7 @@ because of a definition similar to
function Base.showarg(io::IO, v::SubArray, toplevel)
print(io, "view(")
showarg(io, parent(v), false)
print(io, ", ", join(v.indexes, ", "))
print(io, ", ", join(v.indices, ", "))
print(io, ')')
toplevel && print(io, " with eltype ", eltype(v))
end
Expand Down Expand Up @@ -1728,7 +1728,7 @@ end
function showarg(io::IO, v::SubArray, toplevel)
print(io, "view(")
showarg(io, parent(v), false)
showindices(io, v.indexes...)
showindices(io, v.indices...)
print(io, ')')
toplevel && print(io, " with eltype ", eltype(v))
end
Expand Down
6 changes: 3 additions & 3 deletions base/sparse/sparsevector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ count(f, x::SparseVector) = count(f, x.nzval) + f(zero(eltype(x)))*(length(x) -

nonzeros(x::SparseVector) = x.nzval
function nonzeros(x::SparseColumnView)
rowidx, colidx = parentindexes(x)
rowidx, colidx = parentindices(x)
A = parent(x)
@inbounds y = view(A.nzval, nzrange(A, colidx))
return y
end

nonzeroinds(x::SparseVector) = x.nzind
function nonzeroinds(x::SparseColumnView)
rowidx, colidx = parentindexes(x)
rowidx, colidx = parentindices(x)
A = parent(x)
@inbounds y = view(A.rowval, nzrange(A, colidx))
return y
Expand Down Expand Up @@ -105,7 +105,7 @@ LinAlg.fillstored!(x::SparseVector, y) = (fill!(x.nzval, y); x)
### Construction from lists of indices and values

function _sparsevector!(I::Vector{<:Integer}, V::Vector, len::Integer)
# pre-condition: no duplicate indexes in I
# pre-condition: no duplicate indices in I
if !isempty(I)
p = sortperm(I)
permute!(I, p)
Expand Down
2 changes: 1 addition & 1 deletion base/strings/search.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Search for the first occurrence of the given characters within the given string.
argument may be a single character, a vector or a set of characters, a string, or a regular
expression (though regular expressions are only allowed on contiguous strings, such as ASCII
or UTF-8 strings). The third argument optionally specifies a starting index. The return
value is a range of indexes where the matching sequence is found, such that `s[search(s,x)] == x`:
value is a range of indices where the matching sequence is found, such that `s[search(s,x)] == x`:
`search(string, "substring")` = `start:end` such that `string[start:end] == "substring"`, or
`0:-1` if unmatched.
Expand Down
Loading

0 comments on commit 2a776d2

Please sign in to comment.