Skip to content

Commit 2bb647a

Browse files
committed
Merge branch 'master' of github.com:JuliaLang/julia
2 parents 864e266 + 496b559 commit 2bb647a

File tree

11 files changed

+66
-33
lines changed

11 files changed

+66
-33
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ The following distributions include julia, but the versions may be out of date d
395395
* openSUSE
396396
* Stable package for openSUSE: [OBS page](https://build.opensuse.org/package/show/science/julia), [1 Click Install](http://software.opensuse.org/download.html?project=science&package=julia)
397397
* Git package for openSUSE: [OBS page](https://build.opensuse.org/package/show/science/julia-unstable), [1 Click Install](http://software.opensuse.org/download.html?project=science&package=julia-unstable)
398+
* [NixOS](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/compilers/julia)
398399
* Ubuntu
399400
* [Ubuntu 13.04 (Raring Ringtail)](http://packages.ubuntu.com/raring/julia)
400401
* [Nightly builds PPA](https://launchpad.net/~staticfloat/+archive/julianightlies) (depends on the [julia-deps PPA](https://launchpad.net/~staticfloat/+archive/julia-deps/))

base/array.jl

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,20 +1455,24 @@ symdiff(a, b, rest...) = symdiff(a, symdiff(b, rest...))
14551455
_cumsum_type{T<:Number}(v::AbstractArray{T}) = typeof(+zero(T))
14561456
_cumsum_type(v) = typeof(v[1]+v[1])
14571457

1458-
for (f, fp, op) = ((:cumsum, :cumsum_pairwise, :+),
1459-
(:cumprod, :cumprod_pairwise, :*) )
1460-
# in-place cumsum of c = s+v(i1:n), using pairwise summation as for sum
1461-
@eval function ($fp)(v::AbstractVector, c::AbstractVector, s, i1, n)
1458+
for (f, fp, op) = ((:cumsum, :cumsum_pairwise!, :+),
1459+
(:cumprod, :cumprod_pairwise!, :*) )
1460+
# in-place cumsum of c = s+v[range(i1,n)], using pairwise summation
1461+
@eval function ($fp){T}(v::AbstractVector, c::AbstractVector{T}, s, i1, n)
1462+
local s_::T # for sum(v[range(i1,n)]), i.e. sum without s
14621463
if n < 128
1463-
@inbounds c[i1] = ($op)(s, v[i1])
1464+
@inbounds s_ = v[i1]
1465+
@inbounds c[i1] = ($op)(s, s_)
14641466
for i = i1+1:i1+n-1
1465-
@inbounds c[i] = $(op)(c[i-1], v[i])
1467+
@inbounds s_ = $(op)(s_, v[i])
1468+
@inbounds c[i] = $(op)(s, s_)
14661469
end
14671470
else
1468-
n2 = div(n,2)
1469-
($fp)(v, c, s, i1, n2)
1470-
($fp)(v, c, c[(i1+n2)-1], i1+n2, n-n2)
1471+
n2 = n >> 1
1472+
s_ = ($fp)(v, c, s, i1, n2)
1473+
s_ = $(op)(s_, ($fp)(v, c, s + s_, i1+n2, n-n2))
14711474
end
1475+
return s_
14721476
end
14731477

14741478
@eval function ($f)(v::AbstractVector)

base/client.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ function early_init()
375375
get(ENV, "GOTOBLAS_MAIN_FREE", "1"))
376376
Sys.init_sysinfo()
377377
if CPU_CORES > 8 && !("OPENBLAS_NUM_THREADS" in keys(ENV)) && !("OMP_NUM_THREADS" in keys(ENV))
378-
# Prevent openblas from stating to many threads, unless/until specifically requested
378+
# Prevent openblas from starting too many threads, unless/until specifically requested
379379
ENV["OPENBLAS_NUM_THREADS"] = 8
380380
end
381381
end

base/pkg/entry.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,8 +690,8 @@ function test!(pkg::AbstractString, errs::Vector{AbstractString}, notests::Vecto
690690
cd(dirname(test_path)) do
691691
try
692692
color = Base.have_color? "--color=yes" : "--color=no"
693-
codecov = coverage? "--code-coverage=user" : "--code-coverage=none"
694-
run(`$JULIA_HOME/julia $codecov $color $test_path`)
693+
codecov = coverage? "--code-coverage=user --inline=no" : "--code-coverage=none"
694+
run(`$JULIA_HOME/julia --check-bounds=yes $codecov $color $test_path`)
695695
info("$pkg tests passed")
696696
catch err
697697
warnbanner(err, label="[ ERROR: $pkg ]")

base/primes.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ function factor{T<:Integer}(n::T)
9393
n = oftype(n, div(n,p))
9494
end
9595
n == 1 && return h
96+
if isprime(n)
97+
h[n] = 1
98+
return h
99+
end
96100
s = isqrt(n)
97101
end
98102
end
@@ -103,7 +107,9 @@ function factor{T<:Integer}(n::T)
103107
h[p] = get(h,p,0)+1
104108
n = oftype(n, div(n,p))
105109
end
106-
if n == 1
110+
n == 1 && return h
111+
if isprime(n)
112+
h[n] = 1
107113
return h
108114
end
109115
s = isqrt(n)

base/reflection.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,8 @@ function which(f::ANY, t::(Type...))
170170
if !isa(f,Function)
171171
t = tuple(isa(f,Type) ? Type{f} : typeof(f), t...)
172172
f = call
173-
else
174-
if !isgeneric(f)
175-
error("argument is not a generic function")
176-
end
173+
elseif !isgeneric(f)
174+
error("argument is not a generic function")
177175
end
178176
m = ccall(:jl_gf_invoke_lookup, Any, (Any, Any), f, t)
179177
if m === nothing

doc/manual/variables.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ adopt the following conventions:
143143
- Word separation can be indicated by underscores (``'_'``), but use of
144144
underscores is discouraged unless the name would be hard to read otherwise.
145145
- Names of ``Type``\ s begin with a capital letter and word separation is
146-
shown with CamelCase instead of underscores.
146+
shown with upper camel case instead of underscores.
147147
- Names of ``function``\ s and ``macro``\s are in lower case, without
148148
underscores.
149149
- Functions that write to their arguments have names that end in ``!``.

examples/juliatypes.jl

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,6 @@ function exists_issub(x, y, env, anyunions::Bool)
219219
push!(env.Runions.stack, false)
220220
found = exists_issub(x, y, env, true)
221221
pop!(env.Runions.stack)
222-
if env.Lunions.more
223-
return true # return up to forall_exists_issub
224-
end
225222
end
226223
found && return true
227224
end
@@ -230,7 +227,7 @@ end
230227

231228
function issub_union(t, u::UnionT, env, R, state::UnionState)
232229
if state.depth > length(state.stack)
233-
# at a new nesting depth, begin by just counting unions
230+
# indicate that stack needs to grow
234231
state.more = true
235232
return true
236233
end
@@ -339,7 +336,7 @@ function rename(t::UnionAllT)
339336
end
340337

341338
function issub_unionall(t::Ty, u::UnionAllT, env, R)
342-
haskey(env.vars, u.var) && (u = rename(u)) # TODO: tests for this
339+
haskey(env.vars, u.var) && (u = rename(u))
343340
env.vars[u.var] = Bounds(u.var.lb, u.var.ub, R)
344341
ans = R ? issub(t, u.T, env) : issub(u.T, t, env)
345342
delete!(env.vars, u.var)
@@ -634,8 +631,12 @@ function test_3()
634631

635632
@test isequal_type((@UnionAll T tupletype(inst(RefT,T), T)),
636633
(@UnionAll T @UnionAll S<:T tupletype(inst(RefT,T),S)))
634+
@test isequal_type((@UnionAll T tupletype(inst(RefT,T), T)),
635+
(@UnionAll T @UnionAll S<:T @UnionAll R<:S tupletype(inst(RefT,T),R)))
637636
@test isequal_type((@UnionAll T tupletype(inst(RefT,T), T)),
638637
(@UnionAll T @UnionAll T<:S<:T tupletype(inst(RefT,T),S)))
638+
@test issub_strict((@UnionAll T tupletype(inst(RefT,T), T)),
639+
(@UnionAll T @UnionAll S>:T tupletype(inst(RefT,T),S)))
639640
end
640641

641642
# level 4: Union
@@ -684,6 +685,8 @@ end
684685

685686
# level 5: union and UnionAll
686687
function test_5()
688+
u = Ty(Union(Int8,Int))
689+
687690
@test issub(Ty((String,Array{Int,1})),
688691
(@UnionAll T UnionT(tupletype(T,inst(ArrayT,T,1)),
689692
tupletype(T,inst(ArrayT,Ty(Int),1)))))
@@ -697,12 +700,12 @@ function test_5()
697700
@test !issub(Ty((Union(Vector{Int},Vector{Int8}),Vector{Int8})),
698701
@UnionAll T tupletype(inst(ArrayT,T,1), inst(ArrayT,T,1)))
699702

700-
@test !issub(Ty(Vector{Int}), @UnionAll T>:Ty(Union(Int,Int8)) inst(ArrayT,T,1))
701-
@test issub(Ty(Vector{Integer}), @UnionAll T>:Ty(Union(Int,Int8)) inst(ArrayT,T,1))
702-
@test issub(Ty(Vector{Union(Int,Int8)}), @UnionAll T>:Ty(Union(Int,Int8)) inst(ArrayT,T,1))
703+
@test !issub(Ty(Vector{Int}), @UnionAll T>:u inst(ArrayT,T,1))
704+
@test issub(Ty(Vector{Integer}), @UnionAll T>:u inst(ArrayT,T,1))
705+
@test issub(Ty(Vector{Union(Int,Int8)}), @UnionAll T>:u inst(ArrayT,T,1))
703706

704-
@test issub((@UnionAll Ty(Int)<:T<:Ty(Union(Int,Int8)) inst(ArrayT,T,1)),
705-
(@UnionAll Ty(Int)<:T<:Ty(Union(Int,Int8)) inst(ArrayT,T,1)))
707+
@test issub((@UnionAll Ty(Int)<:T<:u inst(ArrayT,T,1)),
708+
(@UnionAll Ty(Int)<:T<:u inst(ArrayT,T,1)))
706709

707710
# with varargs
708711
@test !issub(inst(ArrayT,tupletype(inst(ArrayT,Ty(Int)),inst(ArrayT,Ty(Vector{Int16})),inst(ArrayT,Ty(Vector{Int})),inst(ArrayT,Ty(Int)))),
@@ -716,6 +719,11 @@ function test_5()
716719

717720
@test issub(tupletype(inst(ArrayT,Ty(Int)),inst(ArrayT,Ty(Vector{Int})),inst(ArrayT,Ty(Vector{Int})),inst(ArrayT,Ty(Int))),
718721
@UnionAll S vatype(UnionT(inst(ArrayT,S),inst(ArrayT,inst(ArrayT,S,1)))))
722+
723+
B = @UnionAll S<:u tupletype(S, tupletype(AnyT,AnyT,AnyT), inst(RefT,S))
724+
# these tests require renaming in issub_unionall
725+
@test issub((@UnionAll T<:B tupletype(Ty(Int8), T, inst(RefT,Ty(Int8)))), B)
726+
@test !issub((@UnionAll T<:B tupletype(Ty(Int8), T, inst(RefT,T))), B)
719727
end
720728

721729
# tricky type variable lower bounds
@@ -861,9 +869,13 @@ function test_properties()
861869
@test isequal_type(T, rename(T))
862870
end
863871

872+
# inequality under wrapping
873+
@test !isequal_type(T, inst(RefT,T))
874+
864875
for S in menagerie
876+
issubTS = issub(T, S)
865877
# transitivity
866-
if issub(T, S)
878+
if issubTS
867879
for R in menagerie
868880
if issub(S, R)
869881
@test issub(T, R) # issub(S, R) → issub(T, R)
@@ -879,12 +891,12 @@ function test_properties()
879891
@test isequal_type(T, S) == isequal_type(inst(RefT,T), inst(RefT,S))
880892

881893
# covariance
882-
@test issub(T, S) == issub(tupletype(T), tupletype(S))
883-
@test issub(T, S) == issub(vatype(T), vatype(S))
884-
@test issub(T, S) == issub(tupletype(T), vatype(S))
894+
@test issubTS == issub(tupletype(T), tupletype(S))
895+
@test issubTS == issub(vatype(T), vatype(S))
896+
@test issubTS == issub(tupletype(T), vatype(S))
885897

886898
# contravariance
887-
@test issub(T, S) == issub(¬S, ¬T)
899+
@test issubTS == issub(¬S, ¬T)
888900
end
889901
end
890902
end

src/module.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jl_module_t *jl_new_module(jl_sym_t *name)
2121
m->type = (jl_value_t*)jl_module_type;
2222
assert(jl_is_symbol(name));
2323
m->name = name;
24+
m->parent = NULL;
2425
m->constant_table = NULL;
2526
m->call_func = NULL;
2627
htable_new(&m->bindings, 0);

test/arrayops.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,3 +974,8 @@ a = [ [ 1 0 0 ], [ 0 0 0 ] ]
974974
@test rotl90(a,4) == a
975975
@test rotr90(a,4) == a
976976
@test rot180(a,2) == a
977+
978+
# issue #9648
979+
let x = fill(1.5f0, 10^7)
980+
@test abs(1.5f7 - cumsum(x)[end]) < 3*eps(1.5f7)
981+
end

test/numbers.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2086,3 +2086,9 @@ end
20862086
let x = big(-0.0)
20872087
@test signbit(x) && !signbit(abs(x))
20882088
end
2089+
2090+
# issue #9611
2091+
@test factor(int128(2)^101+1) == Dict(3=>1,845100400152152934331135470251=>1)
2092+
2093+
# test second branch, after all small primes in list have been searched
2094+
@test factor(10009 * int128(1000000000000037)) == Dict(10009=>1,1000000000000037=>1)

0 commit comments

Comments
 (0)