Skip to content

Commit

Permalink
make vcats explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
nolta committed Jan 8, 2014
1 parent 63938e6 commit 8a8a382
Show file tree
Hide file tree
Showing 33 changed files with 78 additions and 78 deletions.
4 changes: 2 additions & 2 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ function circshift(a, shiftamts)
for i=1:n
s = size(a,i)
d = i<=length(shiftamts) ? shiftamts[i] : 0
I[i] = d==0 ? (1:s) : mod([-d:s-1-d], s)+1
I[i] = d==0 ? (1:s) : mod([-d:s-1-d;], s)+1
end
a[I...]::typeof(a)
end
Expand Down Expand Up @@ -1493,7 +1493,7 @@ function mapslices(f::Function, A::AbstractArray, dims::AbstractVector)

dimsA = [size(A)...]
ndimsA = ndims(A)
alldims = [1:ndimsA]
alldims = [1:ndimsA;]

if dims == alldims
return f(A)
Expand Down
2 changes: 1 addition & 1 deletion base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function reinterpret{T,S,N}(::Type{T}, a::Array{S}, dims::NTuple{N,Int})
end
ccall(:jl_reshape_array, Array{T,N}, (Any, Any, Any), Array{T,N}, a, dims)
end
reinterpret(t::Type,x) = reinterpret(t,[x])[1]
reinterpret(t::Type,x) = reinterpret(t,[x;])[1]

function reshape{T,N}(a::Array{T}, dims::NTuple{N,Int})
if prod(dims) != length(a)
Expand Down
2 changes: 1 addition & 1 deletion base/base64.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ end

# Based on code by Stefan Karpinski from https://github.com/hackerschool/WebSockets.jl (distributed under the same MIT license as Julia)

const b64chars = ['A':'Z','a':'z','0':'9','+','/']
const b64chars = ['A':'Z';'a':'z';'0':'9';'+';'/']

function b64(x::Uint8, y::Uint8, z::Uint8)
n = int(x)<<16 | int(y)<<8 | int(z)
Expand Down
6 changes: 3 additions & 3 deletions base/combinatorics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ function combinations(a, t::Integer)
Combinations(a, t)
end

start(c::Combinations) = [1:c.t]
start(c::Combinations) = [1:c.t;]
function next(c::Combinations, s)
comb = c.a[s]
if c.t == 0
Expand Down Expand Up @@ -224,7 +224,7 @@ length(c::Permutations) = factorial(length(c.a))

permutations(a) = Permutations(a)

start(p::Permutations) = [1:length(p.a)]
start(p::Permutations) = [1:length(p.a);]
function next(p::Permutations, s)
if length(p.a) == 0
# special case to generate 1 result for len==0
Expand Down Expand Up @@ -329,7 +329,7 @@ function nextfixedpartition(n, m, bs)
as = copy(bs)
if isempty(as)
# First iteration
as = [n-m+1, ones(Int, m-1)]
as = [n-m+1; ones(Int, m-1)]
elseif as[2] < as[1]-1
# Most common iteration
as[1] -= 1
Expand Down
4 changes: 2 additions & 2 deletions base/dsp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ function conv{T<:Base.LinAlg.BlasFloat}(u::StridedVector{T}, v::StridedVector{T}
nv = length(v)
n = nu + nv - 1
np2 = n > 1024 ? nextprod([2,3,5], n) : nextpow2(n)
upad = [u, zeros(T, np2 - nu)]
vpad = [v, zeros(T, np2 - nv)]
upad = [u; zeros(T, np2 - nu)]
vpad = [v; zeros(T, np2 - nv)]
if T <: Real
p = plan_rfft(upad)
y = irfft(p(upad).*p(vpad), np2)
Expand Down
2 changes: 1 addition & 1 deletion base/fftw.jl
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ function dims_howmany(X::StridedArray, Y::StridedArray,
ist = [strides(X)...]
ost = [strides(Y)...]
dims = [sz[reg] ist[reg] ost[reg]]'
oreg = [1:ndims(X)]
oreg = [1:ndims(X);]
oreg[reg] = 0
oreg = filter(d -> d > 0, oreg)
howmany = [sz[oreg] ist[oreg] ost[oreg]]'
Expand Down
4 changes: 2 additions & 2 deletions base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,7 @@ function typeinf(linfo::LambdaStaticData,atypes::Tuple,sparams::Tuple, def, cop)
la = length(args)
assert(is(ast.head,:lambda))
locals = (ast.args[2][1])::Array{Any,1}
vars = [args, locals]
vars = [args; locals]
body = (ast.args[3].args)::Array{Any,1}
n = length(body)

Expand Down Expand Up @@ -2054,7 +2054,7 @@ function inlining_pass(e::Expr, sv, ast)
return (e,stmts)
end
end
e.args = [{e.args[2]}, newargs...]
e.args = [{e.args[2]}; newargs...]

# now try to inline the simplified call

Expand Down
4 changes: 2 additions & 2 deletions base/intfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ end

num2hex(n::Integer) = hex(n, sizeof(n)*2)

const base36digits = ['0':'9','a':'z']
const base62digits = ['0':'9','A':'Z','a':'z']
const base36digits = ['0':'9';'a':'z']
const base62digits = ['0':'9';'A':'Z';'a':'z']

function base(b::Int, x::Unsigned, pad::Int, neg::Bool)
if !(2 <= b <= 62) error("invalid base: $b") end
Expand Down
2 changes: 1 addition & 1 deletion base/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

## byte-order mark, ntoh & hton ##

const ENDIAN_BOM = reinterpret(Uint32,uint8([1:4]))[1]
const ENDIAN_BOM = reinterpret(Uint32, 0x1:0x4)

if ENDIAN_BOM == 0x01020304
ntoh(x) = identity(x)
Expand Down
6 changes: 3 additions & 3 deletions base/linalg/factorization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ function getindex{T}(A::LU{T}, d::Symbol)
d == :L && return tril(A.factors[1:m, 1:min(m,n)], -1) + eye(T, m, min(m,n))
d == :U && return triu(A.factors[1:min(m,n),1:n])
if d == :p
p = [1:m]
p = [1:m;]
for i in 1:length(A.ipiv)
p[i], p[A.ipiv[i]] = p[A.ipiv[i]], p[i]
end
Expand Down Expand Up @@ -323,8 +323,8 @@ function \{T<:BlasFloat}(A::QRPivoted{T}, B::StridedMatrix{T}, rcond::Real)
tmin, smin, cmin = LAPACK.laic1!(2, sub(xmin, 1:rnk), tmin, sub(A.hh, 1:rnk, rnk + 1), A.hh[rnk + 1, rnk + 1])
tmax, smax, cmax = LAPACK.laic1!(1, sub(xmax, 1:rnk), tmax, sub(A.hh, 1:rnk, rnk + 1), A.hh[rnk + 1, rnk + 1])
tmax*rcond > tmin && break
xmin[1:rnk + 1] = [smin*sub(xmin, 1:rnk), cmin]
xmax[1:rnk + 1] = [smax*sub(xmin, 1:rnk), cmax]
xmin[1:rnk + 1] = [smin*sub(xmin, 1:rnk); cmin]
xmax[1:rnk + 1] = [smax*sub(xmin, 1:rnk); cmax]
rnk += 1
# if cond(r[1:rnk, 1:rnk])*rcond < 1 break end
end
Expand Down
4 changes: 2 additions & 2 deletions base/linalg/generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ function diff(A::AbstractMatrix, dim::Integer)
end


gradient(F::AbstractVector) = gradient(F, [1:length(F)])
gradient(F::AbstractVector, h::Real) = gradient(F, [h*(1:length(F))])
gradient(F::AbstractVector) = gradient(F, [1:length(F);])
gradient(F::AbstractVector, h::Real) = gradient(F, [h*(1:length(F));])
#gradient(F::AbstractVector, h::AbstractVector)

diag(A::AbstractVector) = error("use diagm instead of diag to construct a diagonal matrix")
Expand Down
2 changes: 1 addition & 1 deletion base/linalg/lapack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2113,7 +2113,7 @@ for (stev, stebz, stegr, stein, elty) in
function stegr!(jobz::BlasChar, range::BlasChar, dv::Vector{$elty}, ev::Vector{$elty}, vl::Real, vu::Real, il::Integer, iu::Integer)
n = length(dv)
if length(ev) != (n-1) throw(DimensionMismatch("stebz!")) end
eev = [ev, zero($elty)]
eev = [ev; zero($elty)]
abstol = Array($elty, 1)
m = Array(BlasInt, 1)
w = Array($elty, n)
Expand Down
2 changes: 1 addition & 1 deletion base/multi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ function rmprocs(args...; waitfor = 0.0)
global rmprocset
empty!(rmprocset)

for i in [args...]
for i in vcat(args...)
if i == 1
warn("rmprocs: process 1 not removed")
else
Expand Down
2 changes: 1 addition & 1 deletion base/pkg/resolve/maxsum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ type Graph
end
end

perm = [1:np]
perm = [1:np;]

return new(gadj, gmsk, gdir, adjdict, spp, perm, np)
end
Expand Down
2 changes: 1 addition & 1 deletion base/sort.jl
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ sort(v::AbstractVector; kws...) = sort!(copy(v); kws...)

sortperm(v::AbstractVector; alg::Algorithm=DEFAULT_STABLE,
lt::Function=isless, by::Function=identity, rev::Bool=false, order::Ordering=Forward) =
sort!([1:length(v)], alg, Perm(ord(lt,by,rev,order),v))
sort!([1:length(v);], alg, Perm(ord(lt,by,rev,order),v))

## sorting multi-dimensional arrays ##

Expand Down
6 changes: 3 additions & 3 deletions base/sparse/sparsematrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,8 @@ eye(S::SparseMatrixCSC) = speye(S)

function speye(T::Type, m::Integer, n::Integer)
x = min(m,n)
rowval = [1:x]
colptr = [rowval, fill(int(x+1), n+1-x)]
rowval = [1:x;]
colptr = [rowval; fill(int(x+1), n+1-x)]
nzval = ones(T, x)
return SparseMatrixCSC(m, n, colptr, rowval, nzval)
end
Expand Down Expand Up @@ -934,7 +934,7 @@ end
function getindex{Tv,Ti}(A::SparseMatrixCSC{Tv,Ti}, I::AbstractVector, J::AbstractVector)
m = size(A, 1)

if isa(I, Range) || isa(I, Range1); I = [I]; end
if isa(I, Range) || isa(I, Range1); I = [I;]; end

if I == 1:m
return getindex_cols(A, J)
Expand Down
2 changes: 1 addition & 1 deletion base/string.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1618,7 +1618,7 @@ rsearch(a::ByteArray, b::Union(Int8,Uint8,Char)) = rsearch(a,b,length(a))
# return a random string (often useful for temporary filenames/dirnames)
let
global randstring
const b = uint8(['0':'9','A':'Z','a':'z'])
const b = uint8(['0':'9';'A':'Z';'a':'z'])
randstring(n::Int) = ASCIIString(b[rand(1:length(b),n)])
randstring() = randstring(8)
end
Expand Down
4 changes: 2 additions & 2 deletions src/uv_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const uv_handle_types = [UV_HANDLE_TYPE_MAP(XX) :UV_FILE]
const uv_req_types = [UV_REQ_TYPE_MAP(XX)]
const uv_err_vals = [UV_ERRNO_MAP(YY)]
let
handles = [:UV_UNKNOWN_HANDLE, uv_handle_types, :UV_HANDLE_TYPE_MAX, :UV_RAW_FD, :UV_RAW_HANDLE]
reqs = [:UV_UNKNOWN_REQ, uv_req_types, :UV_REQ_TYPE_PRIVATE,:UV_REQ_TYPE_MAX]
handles = [:UV_UNKNOWN_HANDLE; uv_handle_types; :UV_HANDLE_TYPE_MAX; :UV_RAW_FD; :UV_RAW_HANDLE]
reqs = [:UV_UNKNOWN_REQ; uv_req_types; :UV_REQ_TYPE_PRIVATE; :UV_REQ_TYPE_MAX]
for i=0:(length(handles)-1)
@eval const $(handles[i+1]) = $i
end
Expand Down
32 changes: 16 additions & 16 deletions test/arrayops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ a = reshape(b, (2, 2, 2, 2, 2))
sz = (5,8,7)
A = reshape(1:prod(sz),sz...)
tmp = A[2:6]
@test tmp == [2:6]
@test tmp == [2:6;]
tmp = A[1:3,2,2:4]
@test tmp == cat(3,46:48,86:88,126:128)
tmp = A[:,7:-3:1,5]
Expand Down Expand Up @@ -123,7 +123,7 @@ sA = sub(A, 1:2:3, 1:3:5, 1:2:8)
@test sA[:] == A[1:2:3, 1:3:5, 1:2:8][:]

# sub logical indexing #4763
A = sub([1:10], 5:8)
A = sub(1:10, 5:8)
@test A[A.<7] == [5, 6]
B = reshape(1:16, 4, 4)
sB = sub(B, 2:3, 2:3)
Expand Down Expand Up @@ -153,7 +153,7 @@ sA = slice(A, 1:2:3, 3, 1:2:8)
@test strides(sA) == (2,30)
@test sA[:] == A[sA.indexes...][:]

a = [5:8]
a = 5:8
@test parent(a) == a
@test parentindexes(a) == (1:4,)

Expand Down Expand Up @@ -193,13 +193,13 @@ let
@test x == -12
X = get(A, -5:5, nan(Float32))
@test eltype(X) == Float32
@test isnan(X) == [trues(6),falses(5)]
@test isnan(X) == [trues(6);falses(5)]
@test X[7:11] == 1:5
X = get(A, (2:4, 9:-2:-13), 0)
Xv = zeros(Int, 3, 12)
Xv[1:2, 2:5] = A[2:3, 7:-2:1]
@test X == Xv
X2 = get(A, Vector{Int}[[2:4], [9:-2:-13]], 0)
X2 = get(A, Vector{Int}[[2:4;], [9:-2:-13;]], 0)
@test X == X2
end

Expand All @@ -220,7 +220,7 @@ v = shift!(l)

# concatenation
@test isequal([ones(2,2) 2*ones(2,1)], [1. 1 2; 1 1 2])
@test isequal([ones(2,2), 2*ones(1,2)], [1. 1; 1 1; 2 2])
@test isequal([ones(2,2); 2*ones(1,2)], [1. 1; 1 1; 2 2])

# typed array literals
X = Float64[1 2 3]
Expand Down Expand Up @@ -526,9 +526,9 @@ begin
3 3 4 4 3 3 4 4;
3 3 4 4 3 3 4 4]

A = reshape([1:8], 2, 2, 2)
A = reshape(1:8, 2, 2, 2)
R = repeat(A, inner = [1, 1, 2], outer = [1, 1, 1])
T = reshape([1:4, 1:4, 5:8, 5:8], 2, 2, 4)
T = reshape([1:4; 1:4; 5:8; 5:8], 2, 2, 4)
@test R == T
A = Array(Int, 2, 2, 2)
A[:, :, 1] = [1 2;
Expand Down Expand Up @@ -719,9 +719,9 @@ end
for idx in {1, 2, 5, 9, 10, 1:0, 2:1, 1:1, 2:2, 1:2, 2:4, 9:8, 10:9, 9:9, 10:10,
8:9, 9:10, 6:9, 7:10}
for repl in {[], [11], [11,22], [11,22,33,44,55]}
a = [1:10]; acopy = copy(a)
a = [1:10;]; acopy = copy(a)
@test splice!(a, idx, repl) == acopy[idx]
@test a == [acopy[1:(first(idx)-1)], repl, acopy[(last(idx)+1):end]]
@test a == [acopy[1:(first(idx)-1)]; repl; acopy[(last(idx)+1):end]]
end
end

Expand All @@ -745,15 +745,15 @@ end

# reverse
@test reverse([2,3,1]) == [1,3,2]
@test reverse([1:10],1,4) == [4,3,2,1,5,6,7,8,9,10]
@test reverse([1:10],3,6) == [1,2,6,5,4,3,7,8,9,10]
@test reverse([1:10],6,10) == [1,2,3,4,5,10,9,8,7,6]
@test reverse([1:10;],1,4) == [4,3,2,1,5,6,7,8,9,10]
@test reverse([1:10;],3,6) == [1,2,6,5,4,3,7,8,9,10]
@test reverse([1:10;],6,10) == [1,2,3,4,5,10,9,8,7,6]
@test reverse(1:10,1,4) == [4,3,2,1,5,6,7,8,9,10]
@test reverse(1:10,3,6) == [1,2,6,5,4,3,7,8,9,10]
@test reverse(1:10,6,10) == [1,2,3,4,5,10,9,8,7,6]
@test reverse!([1:10],1,4) == [4,3,2,1,5,6,7,8,9,10]
@test reverse!([1:10],3,6) == [1,2,6,5,4,3,7,8,9,10]
@test reverse!([1:10],6,10) == [1,2,3,4,5,10,9,8,7,6]
@test reverse!([1:10;],1,4) == [4,3,2,1,5,6,7,8,9,10]
@test reverse!([1:10;],3,6) == [1,2,6,5,4,3,7,8,9,10]
@test reverse!([1:10;],6,10) == [1,2,3,4,5,10,9,8,7,6]

# flipdim
@test isequal(flipdim([2,3,1], 1), [1,3,2])
Expand Down
2 changes: 1 addition & 1 deletion test/bigint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ee = typemax(Int64)
@test string(d) == "-246913578024691357802469135780"
@test string(a) == "123456789012345678901234567890"

for i = -10:10, j = [-10:-1,1:10]
for i = -10:10, j = [-10:-1;1:10]
@test div(BigInt(i), BigInt(j)) == div(i,j)
@test fld(BigInt(i), BigInt(j)) == fld(i,j)
@test mod(BigInt(i), BigInt(j)) == mod(i,j)
Expand Down
4 changes: 2 additions & 2 deletions test/blas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ for elty in (Float32, Float64, Complex64, Complex128)

elm1 = convert(elty, -1)
el2 = convert(elty, 2)
v14 = convert(Vector{elty}, [1:4])
v41 = convert(Vector{elty}, [4:-1:1])
v14 = convert(Vector{elty}, [1:4;])
v41 = convert(Vector{elty}, [4:-1:1;])

# dot
if elty <: Real
Expand Down
4 changes: 2 additions & 2 deletions test/combinatorics.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
@test factorial(7) == 5040
@test factorial(7,3) == 7*6*5*4
@test binomial(5,3) == 10
p = shuffle([1:1000])
p = shuffle([1:1000;])
@test isperm(p)
@test all(invperm(invperm(p)) .== p)
push!(p, 1)
@test !isperm(p)
a = randcycle(10)
@test ipermute!(permute!([1:10], a),a) == [1:10]
@test ipermute!(permute!([1:10;], a),a) == [1:10;]
@test collect(combinations("abc",2)) == ["ab","ac","bc"]
@test collect(permutations("abc")) == ["abc","acb","bac","bca","cab","cba"]
@test collect(filter(x->(iseven(x[1])),permutations([1,2,3]))) == {[2,1,3],[2,3,1]}
Expand Down
8 changes: 4 additions & 4 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -679,15 +679,15 @@ end
let
tst = 1
m1(i) = (tst+=1;i-1)
x = [1:4]
x = [1:4;]
x[1:end] *= 2
@test x == [2:2:8]
@test x == [2:2:8;]
x[m1(end)] += 3
@test x == [2,4,9,8]
@test tst == 2

# issue #1886
X = [1:4]
X = [1:4;]
r = Array(Range1{Int},1)
r[1] = 2:3
X[r...] *= 2
Expand Down Expand Up @@ -735,7 +735,7 @@ end

# issue #2098
let
i2098() = (c={2.0};[1:1:c[1]])
i2098() = (c={2.0};[1:1:c[1];])
@test isequal(i2098(), [1.0,2.0])
end

Expand Down
2 changes: 1 addition & 1 deletion test/euler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ end
#23: 4179871

#24: 2783915460
@test nthperm!([0:9],1000000) == [2,7,8,3,9,1,5,4,6,0]
@test nthperm!([0:9;],1000000) == [2,7,8,3,9,1,5,4,6,0]

#25: 4782
#26: 983
Expand Down
Loading

0 comments on commit 8a8a382

Please sign in to comment.