Skip to content

Commit

Permalink
Merge branch 'master' of github.com:JuliaLang/julia
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jan 22, 2015
2 parents 4e66eb0 + 180a6c5 commit f164ac1
Show file tree
Hide file tree
Showing 121 changed files with 1,292 additions and 468 deletions.
9 changes: 6 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,17 @@ Build as usual, and do `make clean testall` to test your contribution. If your c

##### General Formatting Guidelines For Julia code contributions

- 4 space indent
- 4 spaces per indentation level, no tabs
- use whitespace to make the code more readable
- no whitespace at the end of a line
- no whitespace at the end of a line (trailing whitespace)
- comments are good, especially when they explain the algorithm
- try to adhere to a 92 character line length limit
- use upper camel case convention for modules, type names
- use lower case with underscores for method names

##### General Formatting Guidelines For C code contributions

- 4 space indent
- 4 spaces per indentation level, no tabs
- space between if and ( (if (x) ...)
- newline before opening { in function definitions
- f(void) for 0-argument function declarations
Expand Down
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ $(build_docdir):
@mkdir -p $@/examples
@cp -R doc/devdocs doc/manual doc/stdlib $@
@cp -R examples/*.jl $@/examples/
@cp -R examples/clustermanager $@/examples/

git-submodules:
ifneq ($(NO_GIT), 1)
Expand Down Expand Up @@ -152,12 +153,12 @@ $(build_private_libdir)/sys0.o:

BASE_SRCS := $(wildcard base/*.jl base/*/*.jl base/*/*/*.jl)

,:=,
COMMA:=,
$(build_private_libdir)/sys.o: VERSION $(BASE_SRCS) $(build_docdir)/helpdb.jl $(build_private_libdir)/sys0.$(SHLIB_EXT)
@$(call PRINT_JULIA, cd base && \
$(call spawn,$(JULIA_EXECUTABLE)) -C $(JULIA_CPU_TARGET) --build $(call cygpath_w,$(build_private_libdir)/sys) \
-J$(call cygpath_w,$(build_private_libdir))/$$([ -e $(build_private_libdir)/sys.ji ] && echo sys.ji || echo sys0.ji) -f sysimg.jl \
|| { echo '*** This error is usually fixed by running `make clean`. If the error persists$(,) try `make cleanall`. ***' && false; } )
|| { echo '*** This error is usually fixed by running `make clean`. If the error persists$(COMMA) try `make cleanall`. ***' && false; } )

$(build_bindir)/stringreplace: contrib/stringreplace.c | $(build_bindir)
@$(call PRINT_CC, $(CC) -o $(build_bindir)/stringreplace contrib/stringreplace.c)
Expand Down Expand Up @@ -448,17 +449,17 @@ distcleanall: cleanall
run-julia run-julia-debug run-julia-release run \
install dist source-dist git-submodules

test: release
test: check-whitespace release
@$(MAKE) $(QUIET_MAKE) -C test default

testall: release
testall: check-whitespace release
cp $(build_prefix)/lib/julia/sys.ji local.ji && $(JULIA_EXECUTABLE) -J local.ji -e 'true' && rm local.ji
@$(MAKE) $(QUIET_MAKE) -C test all

testall1: release
testall1: check-whitespace release
@env JULIA_CPU_CORES=1 $(MAKE) $(QUIET_MAKE) -C test all

test-%: release
test-%: check-whitespace release
@$(MAKE) $(QUIET_MAKE) -C test $*

perf: release
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ Library improvements

* Split `Triangular` type into `UpperTriangular`, `LowerTriangular`, `UnitUpperTriagular` and `UnitLowerTriangular` ([#9779])

* ClusterManager - Performance improvements([#9309]) and support for changing transports([#9434])

Deprecated or removed
---------------------

Expand Down
2 changes: 1 addition & 1 deletion base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ndims{T<:AbstractArray}(::Type{T}) = ndims(super(T))
length(t::AbstractArray) = prod(size(t))::Int
endof(a::AbstractArray) = length(a)
first(a::AbstractArray) = a[1]
first(a) = (s = start(a); done(a, s) ? error("collection is empty") : next(a, s)[1])
first(a) = (s = start(a); done(a, s) ? throw(ArgumentError("collection must be non-empty")) : next(a, s)[1])
last(a) = a[end]
ctranspose(a::AbstractArray) = error("ctranspose not implemented for $(typeof(a)). Consider adding parentheses, e.g. A*(B*C') instead of A*B*C' to avoid explicit calculation of the transposed matrix.")
transpose(a::AbstractArray) = error("transpose not implemented for $(typeof(a)). Consider adding parentheses, e.g. A*(B*C.') instead of A*B*C' to avoid explicit calculation of the transposed matrix.")
Expand Down
4 changes: 3 additions & 1 deletion base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,9 @@ end
function hcat{T}(V::Vector{T}...)
height = length(V[1])
for j = 2:length(V)
if length(V[j]) != height; throw(ArgumentError("vector must have same lengths")); end
if length(V[j]) != height
throw(DimensionMismatch("vectors must have same lengths"))
end
end
[ V[j][i]::T for i=1:length(V[1]), j=1:length(V) ]
end
Expand Down
6 changes: 5 additions & 1 deletion base/ascii.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ write(io::IO, s::ASCIIString) = write(io, s.data)
ascii(x) = convert(ASCIIString, x)
convert(::Type{ASCIIString}, s::ASCIIString) = s
convert(::Type{ASCIIString}, s::UTF8String) = ascii(s.data)
convert(::Type{ASCIIString}, a::Array{UInt8,1}) = is_valid_ascii(a) ? ASCIIString(a) : error("invalid ASCII sequence")
convert(::Type{ASCIIString}, a::Vector{UInt8}) = begin
is_valid_ascii(a) || throw(ArgumentError("invalid ASCII sequence"))
return ASCIIString(a)
end

function convert(::Type{ASCIIString}, a::Array{UInt8,1}, invalids_as::ASCIIString)
l = length(a)
idx = 1
Expand Down
2 changes: 1 addition & 1 deletion base/base64.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ end
#Returns the first decoded byte and stores up to two more in cache
function b64decode!(encvec::Vector{UInt8}, cache::Vector{UInt8})
if length(encvec) < 2
error("Incorrect base64 format")
throw(ArgumentError("incorrect base64 format, block must be at least 2 and at most 4 bytes"))
end
@inbounds u = revb64chars[encvec[1]]
@inbounds v = revb64chars[encvec[2]]
Expand Down
45 changes: 31 additions & 14 deletions base/bitarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ type BitArray{N} <: DenseArray{Bool, N}
len::Int
dims::NTuple{N,Int}
function BitArray(dims::Int...)
length(dims) == N || error("number of dimensions must be $N (got $(length(dims)))")
length(dims) == N || throw(ArgumentError("number of dimensions must be $N, got $(length(dims))"))
n = 1
i = 1
for d in dims
d >= 0 || error("dimension size must be nonnegative (got $d)")
d >= 0 || throw(ArgumentError("dimension size must be ≥ 0, got $d for dimension $i"))
n *= d
i += 1
end
nc = num_bit_chunks(n)
chunks = Array(UInt64, nc)
Expand All @@ -34,7 +36,14 @@ length(B::BitArray) = B.len
size(B::BitVector) = (B.len,)
size(B::BitArray) = B.dims

size(B::BitVector, d) = (d==1 ? B.len : d>1 ? 1 : error("dimensions should be positive (got $d)"))
size(B::BitVector, d) = begin
if d == 1
return B.len
elseif d > 1
return 1
end
throw(ArgumentError("dimension must be ≥ 1, got $d"))
end
size{N}(B::BitArray{N}, d) = (d>N ? 1 : B.dims[d])

isassigned{N}(B::BitArray{N}, i::Int) = 1 <= i <= length(B)
Expand Down Expand Up @@ -592,7 +601,7 @@ function resize!(B::BitVector, n::Integer)
end

function pop!(B::BitVector)
isempty(B) && error("argument must not be empty")
isempty(B) && throw(ArgumentError("argument must not be empty"))
item = B[end]
B[end] = false

Expand Down Expand Up @@ -626,7 +635,7 @@ function unshift!(B::BitVector, item)
end

function shift!(B::BitVector)
isempty(B) && error("argument must not be empty")
isempty(B) && throw(ArgumentError("argument must not be empty"))
@inbounds begin
item = B[1]

Expand Down Expand Up @@ -753,7 +762,7 @@ function deleteat!(B::BitVector, inds)
while !done(inds, s)
(i,s) = next(inds, s)
if !(q <= i <= n)
i < q && error("indices must be unique and sorted")
i < q && throw(ArgumentError("indices must be unique and sorted"))
throw(BoundsError(B, i))
end
new_l -= 1
Expand Down Expand Up @@ -1540,8 +1549,8 @@ function any(B::BitArray)
return false
end

minimum(B::BitArray) = isempty(B) ? error("argument must be non-empty") : all(B)
maximum(B::BitArray) = isempty(B) ? error("argument must be non-empty") : any(B)
minimum(B::BitArray) = isempty(B) ? throw(ArgumentError("argument must be non-empty")) : all(B)
maximum(B::BitArray) = isempty(B) ? throw(ArgumentError("argument must be non-empty")) : any(B)

## map over bitarrays ##

Expand Down Expand Up @@ -1682,7 +1691,7 @@ ctranspose(B::BitArray) = transpose(B)
function permutedims(B::Union(BitArray,StridedArray), perm)
dimsB = size(B)
ndimsB = length(dimsB)
(ndimsB == length(perm) && isperm(perm)) || error("no valid permutation of dimensions")
(ndimsB == length(perm) && isperm(perm)) || throw(ArgumentError("no valid permutation of dimensions"))
dimsP = ntuple(ndimsB, i->dimsB[perm[i]])::typeof(dimsB)
P = similar(B, dimsP)
permutedims!(P, B, perm)
Expand All @@ -1694,7 +1703,9 @@ end
function hcat(B::BitVector...)
height = length(B[1])
for j = 2:length(B)
length(B[j]) == height || error("dimensions must match")
if length(B[j]) != height
throw(DimensionMismatch("dimensions must match"))
end
end
M = BitArray(height, length(B))
for j = 1:length(B)
Expand Down Expand Up @@ -1726,7 +1737,9 @@ function hcat(A::Union(BitMatrix,BitVector)...)
Aj = A[j]
nd = ndims(Aj)
ncols += (nd==2 ? size(Aj,2) : 1)
if size(Aj, 1) != nrows; error("rows must match"); end
if size(Aj, 1) != nrows
throw(DimensionMismatch("row lengths must match"))
end
end

B = BitArray(nrows, ncols)
Expand All @@ -1746,7 +1759,9 @@ function vcat(A::BitMatrix...)
nrows = sum(a->size(a, 1), A)::Int
ncols = size(A[1], 2)
for j = 2:nargs
size(A[j], 2) == ncols || error("columns must match")
if size(A[j], 2) != ncols
throw(DimensionMismatch("column lengths must match"))
end
end
B = BitArray(nrows, ncols)
Bc = B.chunks
Expand Down Expand Up @@ -1784,14 +1799,16 @@ function cat(catdim::Integer, X::Union(BitArray, Integer)...)

if catdim > d_max + 1
for i = 1:nargs
dimsX[1] == dimsX[i] || error("all inputs must have same dimensions when concatenating along a higher dimension");
if dimsX[1] != dimsX[i]
throw(DimensionMismatch("all inputs must have same dimensions when concatenating along a higher dimension"))
end
end
elseif nargs >= 2
for d = 1:d_max
d == catdim && continue
len = d <= ndimsX[1] ? dimsX[1][d] : 1
for i = 2:nargs
len == (d <= ndimsX[i] ? dimsX[i][d] : 1) || error("mismatch in dimension ", d)
len == (d <= ndimsX[i] ? dimsX[i][d] : 1) || throw(DimensionMismatch("mismatch in dimension $d"))
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions base/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function broadcast_shape(As::Union(AbstractArray,Number)...)
if bshape[d] == 1
bshape[d] = n
elseif bshape[d] != n
error("arrays could not be broadcast to a common size")
throw(DimensionMismatch("arrays could not be broadcast to a common size"))
end
end
end
Expand All @@ -49,12 +49,12 @@ end
function check_broadcast_shape(shape::Dims, As::Union(AbstractArray,Number)...)
for A in As
if ndims(A) > length(shape)
error("cannot broadcast array to have fewer dimensions")
throw(DimensionMismatch("cannot broadcast array to have fewer dimensions"))
end
for k in 1:ndims(A)
n, nA = shape[k], size(A, k)
if n != nA != 1
error("array could not be broadcast to match destination")
throw(DimensionMismatch("array could not be broadcast to match destination"))
end
end
end
Expand Down
Loading

0 comments on commit f164ac1

Please sign in to comment.