Skip to content

Commit 4df9429

Browse files
authored
Updates for Julia 1.0 (#11)
1 parent 1ad8910 commit 4df9429

File tree

5 files changed

+15
-46
lines changed

5 files changed

+15
-46
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ language: julia
22
os:
33
- linux
44
julia:
5-
- 0.6
5+
- 1.0
66
- nightly
77
notifications:
88
email: false
99
#script: # the default script is equivalent to the following
1010
# - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
1111
# - julia -e 'Pkg.clone(pwd()); Pkg.build("KahanSummation"); Pkg.test("KahanSummation"; coverage=true)';
1212
after_success:
13-
- julia -e 'cd(Pkg.dir("KahanSummation")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())';
14-
- julia -e 'cd(Pkg.dir("KahanSummation")); Pkg.add("Documenter"); include(joinpath("docs", "make.jl"))';
13+
- julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())';
14+
- julia -e 'using Pkg; Pkg.add("Documenter"); include(joinpath("docs", "make.jl"))';

REQUIRE

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
julia 0.6
2-
Compat 0.33.0
1+
julia 1.0

docs/make.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ makedocs(
1212
)
1313

1414
deploydocs(
15-
julia = "0.6",
15+
julia = "1.0",
1616
repo = "github.com/JuliaMath/KahanSummation.jl.git",
1717
target = "build",
1818
deps = nothing,

src/KahanSummation.jl

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,9 @@
11
# This file contains code that was formerly a part of Julia.
22
# License is MIT: https://julialang.org/license
33

4-
VERSION < v"0.7.0-beta2.199" && __precompile__()
5-
64
module KahanSummation
75

8-
if VERSION >= v"0.7.0-DEV.3000" # TODO: More specific bound
9-
if isdefined(Base, :sum_kbn) # Deprecated
10-
import Base: sum_kbn, cumsum_kbn
11-
else
12-
export sum_kbn, cumsum_kbn
13-
end
14-
end
15-
16-
if isdefined(Base, Symbol("@default_eltype"))
17-
using Base: @default_eltype
18-
else
19-
macro default_eltype(itr)
20-
quote
21-
Core.Inference.return_type(first, Tuple{$(esc(itr))})
22-
end
23-
end
24-
end
25-
26-
if isdefined(Base, :promote_sys_size_add)
27-
using Base: promote_sys_size_add
28-
else
29-
promote_sys_size_add(x::T) where {T} = Base.r_promote(+, zero(T)::T)
30-
end
6+
export sum_kbn, cumsum_kbn
317

328
"""
339
cumsum_kbn(A, dim::Integer)
@@ -67,7 +43,7 @@ end
6743
function cumsum_kbn(v::AbstractVector{T}) where T<:AbstractFloat
6844
r = similar(v)
6945
isempty(v) && return r
70-
inds = indices(v, 1)
46+
inds = axes(v, 1)
7147
i1 = first(inds)
7248
s = r[i1] = v[i1]
7349
c = zero(T)
@@ -92,16 +68,14 @@ Return the sum of all elements of `A`, using the Kahan-Babuska-Neumaier compensa
9268
summation algorithm for additional accuracy.
9369
"""
9470
function sum_kbn(A)
95-
T = @default_eltype(typeof(A))
96-
c = promote_sys_size_add(zero(T)::T)
97-
i = start(A)
98-
if done(A, i)
99-
return c
100-
end
101-
Ai, i = next(A, i)
71+
T = Base.@default_eltype(A)
72+
c = Base.reduce_empty(+, T)
73+
it = iterate(A)
74+
it === nothing && return c
75+
Ai, i = it
10276
s = Ai - c
103-
while !(done(A, i))
104-
Ai, i = next(A, i)
77+
while (it = iterate(A, i)) !== nothing
78+
Ai, i = it
10579
t = s + Ai
10680
if abs(s) >= abs(Ai)
10781
c -= ((s-t) + Ai)

test/runtests.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
# License is MIT: https://julialang.org/license
33

44
using KahanSummation
5-
using Compat
6-
using Compat.Test
7-
8-
# Shadow the names in Base if they're defined
9-
import KahanSummation: sum_kbn, cumsum_kbn
5+
using Test
106

117
@testset "cumsum_kbn" begin
128
v = [1,1e100,1,-1e100]*1000

0 commit comments

Comments
 (0)