Skip to content

Commit

Permalink
Merge pull request #23670 from JuliaLang/aa/backports-0.6
Browse files Browse the repository at this point in the history
Backports for 0.6.1
  • Loading branch information
ararslan authored Oct 7, 2017
2 parents 4aa661a + f651277 commit 389b23c
Show file tree
Hide file tree
Showing 142 changed files with 3,687 additions and 1,334 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ This section lists changes that do not have deprecation warnings.
* `homedir` now determines the user's home directory via `libuv`'s `uv_os_homedir`,
rather than from environment variables ([#19636]).
* Workers now listen on an ephemeral port assigned by the OS. Previously workers would
listen on the first free port available from 9009 ([#21818]).
Library improvements
--------------------
Expand Down
11 changes: 8 additions & 3 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,10 @@ function checkbounds_indices(::Type{Bool}, IA::Tuple, I::Tuple{Any})
end
function checkbounds_linear_indices(::Type{Bool}, IA::Tuple{Vararg{OneTo}}, i)
@_inline_meta
if checkindex(Bool, IA[1], i)
ts = trailingsize(IA)
if checkindex(Bool, IA[1], i) && ts > 0
return true
elseif checkindex(Bool, OneTo(trailingsize(IA)), i) # partial linear indexing
elseif checkindex(Bool, OneTo(ts), i) # partial linear indexing
partial_linear_indexing_warning_lookup(length(IA))
return true # TODO: Return false after the above function is removed in deprecated.jl
end
Expand Down Expand Up @@ -801,7 +802,7 @@ A[iter] = 0
If you supply more than one `AbstractArray` argument, `eachindex` will create an
iterable object that is fast for all arguments (a `UnitRange`
if all inputs have fast linear indexing, a `CartesianRange`
if all inputs have fast linear indexing, a [`CartesianRange`](@ref)
otherwise).
If the arrays have different sizes and/or dimensionalities, `eachindex` returns an
iterable that spans the largest range along each dimension.
Expand Down Expand Up @@ -1718,6 +1719,7 @@ For multiple iterable arguments, `f` is called elementwise.
`foreach` should be used instead of `map` when the results of `f` are not
needed, for example in `foreach(println, array)`.
# Example
```jldoctest
julia> a = 1:3:7;
Expand Down Expand Up @@ -1745,6 +1747,7 @@ colons go in this expression. The results are concatenated along the remaining d
For example, if `dims` is `[1,2]` and `A` is 4-dimensional, `f` is called on `A[:,:,i,j]`
for all `i` and `j`.
# Examples
```jldoctest
julia> a = reshape(collect(1:16),(2,2,2,2))
2×2×2×2 Array{Int64,4}:
Expand Down Expand Up @@ -1871,6 +1874,7 @@ map(f, A::Union{AbstractArray,AbstractSet,Associative}) = collect_similar(A, Gen
Transform collection `c` by applying `f` to each element. For multiple collection arguments,
apply `f` elementwise.
# Examples
```jldoctest
julia> map(x -> x * 2, [1, 2, 3])
3-element Array{Int64,1}:
Expand Down Expand Up @@ -1913,6 +1917,7 @@ end
Like [`map`](@ref), but stores the result in `destination` rather than a new
collection. `destination` must be at least as large as the first collection.
# Example
```jldoctest
julia> x = zeros(3);
Expand Down
15 changes: 13 additions & 2 deletions base/abstractarraymath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Reshape the array `a` as a one-dimensional column vector. The resulting array
shares the same underlying data as `a`, so modifying one will also modify the
other.
# Example
```jldoctest
julia> a = [1 2 3; 4 5 6]
2×3 Array{Int64,2}:
Expand Down Expand Up @@ -48,6 +49,7 @@ Remove the dimensions specified by `dims` from array `A`.
Elements of `dims` must be unique and within the range `1:ndims(A)`.
`size(A,i)` must equal 1 for all `i` in `dims`.
# Example
```jldoctest
julia> a = reshape(collect(1:4),(2,2,1,1))
2×2×1×1 Array{Int64,4}:
Expand Down Expand Up @@ -101,6 +103,7 @@ imag(x::AbstractArray{<:Real}) = zero(x)
Return all the data of `A` where the index for dimension `d` equals `i`. Equivalent to
`A[:,:,...,i,:,:,...]` where `i` is in position `d`.
# Example
```jldoctest
julia> A = [1 2 3 4; 5 6 7 8]
2×4 Array{Int64,2}:
Expand All @@ -125,6 +128,7 @@ end
Reverse `A` in dimension `d`.
# Example
```jldoctest
julia> b = [1 2; 3 4]
2×2 Array{Int64,2}:
Expand Down Expand Up @@ -177,6 +181,7 @@ circshift(a::AbstractArray, shiftamt::DimsInteger) = circshift!(similar(a), a, s
Circularly shift the data in an array. The second argument is a vector giving the amount to
shift in each dimension.
# Example
```jldoctest
julia> b = reshape(collect(1:16), (4,4))
4×4 Array{Int64,2}:
Expand Down Expand Up @@ -281,6 +286,7 @@ end
Construct a matrix by repeating the given matrix (or vector) `m` times in dimension 1 and `n` times in
dimension 2.
# Examples
```jldoctest
julia> repmat([1, 2, 3], 2)
6-element Array{Int64,1}:
Expand Down Expand Up @@ -337,6 +343,7 @@ repeated. The i-th element of `outer` specifies the number of times that a slice
i-th dimension of `A` should be repeated. If `inner` or `outer` are omitted, no repetition
is performed.
# Examples
```jldoctest
julia> repeat(1:2, inner=2)
4-element Array{Int64,1}:
Expand Down Expand Up @@ -390,7 +397,11 @@ _rshps(shp, shp_i, sz, i, ::Tuple{}) =
_reperr(s, n, N) = throw(ArgumentError("number of " * s * " repetitions " *
"($n) cannot be less than number of dimensions of input ($N)"))

@propagate_inbounds function _repeat(A::AbstractArray, inner, outer)
# We need special handling when repeating arrays of arrays
cat_fill!(R, X, inds) = (R[inds...] = X)
cat_fill!(R, X::AbstractArray, inds) = fill!(view(R, inds...), X)

@noinline function _repeat(A::AbstractArray, inner, outer)
shape, inner_shape = rep_shapes(A, inner, outer)

R = similar(A, shape)
Expand All @@ -408,7 +419,7 @@ _reperr(s, n, N) = throw(ArgumentError("number of " * s * " repetitions " *
n = inner[i]
inner_indices[i] = (1:n) + ((c[i] - 1) * n)
end
R[inner_indices...] = A[c]
cat_fill!(R, A[c], inner_indices)
end
end

Expand Down
Loading

0 comments on commit 389b23c

Please sign in to comment.