Skip to content

Commit

Permalink
Merge branch 'master' into ajf/conjarray
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKarpinski authored Feb 3, 2017
2 parents a1b2763 + 3d4b312 commit e8f20b5
Show file tree
Hide file tree
Showing 155 changed files with 3,874 additions and 3,116 deletions.
610 changes: 610 additions & 0 deletions HISTORY.md

Large diffs are not rendered by default.

629 changes: 14 additions & 615 deletions NEWS.md

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions base/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,9 @@ LineEditREPL(t::TextTerminal, envcolors = false) = LineEditREPL(t,
Base.text_colors[:yellow],
false, false, false, envcolors)

type REPLCompletionProvider <: CompletionProvider
r::LineEditREPL
end
type REPLCompletionProvider <: CompletionProvider; end

type ShellCompletionProvider <: CompletionProvider
r::LineEditREPL
end
type ShellCompletionProvider <: CompletionProvider; end

immutable LatexCompletions <: CompletionProvider; end

Expand Down Expand Up @@ -713,7 +709,7 @@ function setup_interface(repl::LineEditREPL; hascolor = repl.hascolor, extra_rep
############################### Stage I ################################

# This will provide completions for REPL and help mode
replc = REPLCompletionProvider(repl)
replc = REPLCompletionProvider()

# Set up the main Julia prompt
julia_prompt = Prompt(JULIA_PROMPT;
Expand Down Expand Up @@ -741,7 +737,7 @@ function setup_interface(repl::LineEditREPL; hascolor = repl.hascolor, extra_rep
prompt_suffix = hascolor ?
(repl.envcolors ? Base.input_color : repl.input_color) : "",
keymap_func_data = repl,
complete = ShellCompletionProvider(repl),
complete = ShellCompletionProvider(),
# Transform "foo bar baz" into `foo bar baz` (shell quoting)
# and pass into Base.repl_cmd for processing (handles `ls` and `cd`
# special)
Expand Down
4 changes: 2 additions & 2 deletions base/Terminals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ cmove_up(t::UnixTerminal, n) = write(t.out_stream, "$(CSI)$(n)A")
cmove_down(t::UnixTerminal, n) = write(t.out_stream, "$(CSI)$(n)B")
cmove_right(t::UnixTerminal, n) = write(t.out_stream, "$(CSI)$(n)C")
cmove_left(t::UnixTerminal, n) = write(t.out_stream, "$(CSI)$(n)D")
cmove_line_up(t::UnixTerminal, n) = (cmove_up(t, n); cmove_col(t, 0))
cmove_line_down(t::UnixTerminal, n) = (cmove_down(t, n); cmove_col(t, 0))
cmove_line_up(t::UnixTerminal, n) = (cmove_up(t, n); cmove_col(t, 1))
cmove_line_down(t::UnixTerminal, n) = (cmove_down(t, n); cmove_col(t, 1))
cmove_col(t::UnixTerminal, n) = write(t.out_stream, "$(CSI)$(n)G")

if is_windows()
Expand Down
39 changes: 18 additions & 21 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ julia> size(A, 2)
3
julia> size(A,3,2)
(4,3)
(4, 3)
```
"""
size{T,N}(t::AbstractArray{T,N}, d) = d <= N ? size(t)[d] : 1
Expand Down Expand Up @@ -48,7 +48,7 @@ Returns the tuple of valid indices for array `A`.
julia> A = ones(5,6,7);
julia> indices(A)
(Base.OneTo(5),Base.OneTo(6),Base.OneTo(7))
(Base.OneTo(5), Base.OneTo(6), Base.OneTo(7))
```
"""
function indices(A)
Expand Down Expand Up @@ -84,7 +84,7 @@ julia> A = ones(5,6,7);
julia> b = linearindices(A);
julia> extrema(b)
(1,210)
(1, 210)
```
"""
linearindices(A) = (@_inline_meta; OneTo(_length(A)))
Expand Down Expand Up @@ -199,7 +199,7 @@ Returns a tuple of the memory strides in each dimension.
julia> A = ones(3,4,5);
julia> strides(A)
(1,3,12)
(1, 3, 12)
```
"""
strides(A::AbstractArray) = _strides((1,), A)
Expand Down Expand Up @@ -716,17 +716,17 @@ julia> for iter in eachindex(A)
@show iter.I[1], iter.I[2]
@show A[iter]
end
(iter.I[1],iter.I[2]) = (1,1)
(iter.I[1], iter.I[2]) = (1, 1)
A[iter] = 1
(iter.I[1],iter.I[2]) = (2,1)
(iter.I[1], iter.I[2]) = (2, 1)
A[iter] = -5
(iter.I[1],iter.I[2]) = (1,2)
(iter.I[1], iter.I[2]) = (1, 2)
A[iter] = 0
(iter.I[1],iter.I[2]) = (2,2)
(iter.I[1], iter.I[2]) = (2, 2)
A[iter] = 0
(iter.I[1],iter.I[2]) = (1,3)
(iter.I[1], iter.I[2]) = (1, 3)
A[iter] = 2
(iter.I[1],iter.I[2]) = (2,3)
(iter.I[1], iter.I[2]) = (2, 3)
A[iter] = 0
```
Expand Down Expand Up @@ -1142,10 +1142,7 @@ julia> vcat(a,b)
11 12 13 14 15
julia> c = ([1 2 3], [4 5 6])
(
[1 2 3],
[4 5 6])
([1 2 3], [4 5 6])
julia> vcat(c...)
2×3 Array{Int64,2}:
Expand Down Expand Up @@ -1185,7 +1182,7 @@ julia> hcat(a,b)
5 14 15
julia> c = ([1; 2; 3], [4; 5; 6])
([1,2,3],[4,5,6])
([1, 2, 3], [4, 5, 6])
julia> hcat(c...)
3×2 Array{Int64,2}:
Expand Down Expand Up @@ -1237,7 +1234,7 @@ row.
```jldoctest
julia> a, b, c, d, e, f = 1, 2, 3, 4, 5, 6
(1,2,3,4,5,6)
(1, 2, 3, 4, 5, 6)
julia> [a b c; d e f]
2×3 Array{Int64,2}:
Expand Down Expand Up @@ -1444,10 +1441,10 @@ Returns a tuple of subscripts into array `a` corresponding to the linear index `
julia> A = ones(5,6,7);
julia> ind2sub(A,35)
(5,1,2)
(5, 1, 2)
julia> ind2sub(A,70)
(5,2,3)
(5, 2, 3)
```
"""
function ind2sub(A::AbstractArray, ind)
Expand Down Expand Up @@ -1517,13 +1514,13 @@ provides the indices of the maximum element.
```jldoctest
julia> ind2sub((3,4),2)
(2,1)
(2, 1)
julia> ind2sub((3,4),3)
(3,1)
(3, 1)
julia> ind2sub((3,4),4)
(1,2)
(1, 2)
```
"""
ind2sub(dims::DimsInteger, ind::Integer) = (@_inline_meta; _ind2sub(dims, ind-1))
Expand Down
2 changes: 1 addition & 1 deletion base/abstractarraymath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function slicedim(A::AbstractArray, d::Integer, i)
d >= 1 || throw(ArgumentError("dimension must be ≥ 1"))
nd = ndims(A)
d > nd && (i == 1 || throw_boundserror(A, (ntuple(k->Colon(),nd)..., ntuple(k->1,d-1-nd)..., i)))
A[( n==d ? i : indices(A,n) for n in 1:nd )...]
A[setindex(indices(A), i, d)...]
end

function flipdim(A::AbstractVector, d::Integer)
Expand Down
18 changes: 9 additions & 9 deletions base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1426,15 +1426,15 @@ julia> A = [1 2 0; 0 0 3; 0 4 0]
0 4 0
julia> findn(A)
([1,1,3,2],[1,2,2,3])
([1, 1, 3, 2], [1, 2, 2, 3])
julia> A = zeros(2,2)
2×2 Array{Float64,2}:
0.0 0.0
0.0 0.0
julia> findn(A)
(Int64[],Int64[])
(Int64[], Int64[])
```
"""
function findn(A::AbstractMatrix)
Expand Down Expand Up @@ -1466,7 +1466,7 @@ julia> A = [1 2 0; 0 0 3; 0 4 0]
0 4 0
julia> findnz(A)
([1,1,3,2],[1,2,2,3],[1,2,4,3])
([1, 1, 3, 2], [1, 2, 2, 3], [1, 2, 4, 3])
```
"""
function findnz{T}(A::AbstractMatrix{T})
Expand Down Expand Up @@ -1500,13 +1500,13 @@ The collection must not be empty.
```jldoctest
julia> findmax([8,0.1,-9,pi])
(8.0,1)
(8.0, 1)
julia> findmax([1,7,7,6])
(7,2)
(7, 2)
julia> findmax([1,7,7,NaN])
(7.0,2)
(7.0, 2)
```
"""
function findmax(a)
Expand Down Expand Up @@ -1538,13 +1538,13 @@ The collection must not be empty.
```jldoctest
julia> findmin([8,0.1,-9,pi])
(-9.0,3)
(-9.0, 3)
julia> findmin([7,1,1,6])
(1,2)
(1, 2)
julia> findmin([7,1,1,NaN])
(1.0,2)
(1.0, 2)
```
"""
function findmin(a)
Expand Down
10 changes: 8 additions & 2 deletions base/associative.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ in(k, v::KeyIterator) = get(v.dict, k, secret_table_token) !== secret_table_toke
keys(a::Associative)
Return an iterator over all keys in a collection.
`collect(keys(d))` returns an array of keys.
`collect(keys(a))` returns an array of keys.
Since the keys are stored internally in a hash table,
the order in which they are returned may vary.
But `keys(a)` and `values(a)` both iterate `a` and
return the elements in the same order.
```jldoctest
julia> a = Dict('a'=>2, 'b'=>3)
Expand All @@ -87,7 +89,11 @@ eachindex(a::Associative) = KeyIterator(a)
values(a::Associative)
Return an iterator over all values in a collection.
`collect(values(d))` returns an array of values.
`collect(values(a))` returns an array of values.
Since the values are stored internally in a hash table,
the order in which they are returned may vary.
But `keys(a)` and `values(a)` both iterate `a` and
return the elements in the same order.
```jldoctest
julia> a = Dict('a'=>2, 'b'=>3)
Expand Down
39 changes: 10 additions & 29 deletions base/bitarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1278,39 +1278,20 @@ end

## Data movement ##

# TODO some of this could be optimized

function slicedim(A::BitArray, d::Integer, i::Integer)
d_in = size(A)
leading = d_in[1:(d-1)]
d_out = tuple(leading..., d_in[(d+1):end]...)

M = prod(leading)
N = length(A)
stride = M * d_in[d]

B = BitArray(d_out)
index_offset = 1 + (i-1)*M

l = 1

if M == 1
for j = 0:stride:(N-stride)
B[l] = A[j + index_offset]
l += 1
end
# preserve some special behavior
function slicedim(A::BitVector, d::Integer, i::Integer)
d >= 1 || throw(ArgumentError("dimension must be ≥ 1"))
if d > 1
i == 1 || throw_boundserror(A, (:, ntuple(k->1,d-2)..., i))
A[:]
else
for j = 0:stride:(N-stride)
offs = j + index_offset
for k = 0:(M-1)
B[l] = A[offs + k]
l += 1
end
end
fill!(BitArray{0}(), A[i]) # generic slicedim would return A[i] here
end
return B
end


# TODO some of this could be optimized

function flipdim(A::BitArray, d::Integer)
nd = ndims(A)
1 d nd || throw(ArgumentError("dimension $d is not 1 ≤ $d$nd"))
Expand Down
1 change: 0 additions & 1 deletion base/boot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@ typealias NTuple{N,T} Tuple{Vararg{T,N}}
(::Type{Array{T}}){T}(m::Int, n::Int, o::Int) = Array{T,3}(m, n, o)

(::Type{Array{T,1}}){T}() = Array{T,1}(0)
(::Type{Array{T,2}}){T}() = Array{T,2}(0, 0)

# primitive Symbol constructors
function Symbol(s::String)
Expand Down
Loading

0 comments on commit e8f20b5

Please sign in to comment.