Skip to content

Commit b12f447

Browse files
committed
add iterator traits for #8
1 parent 29d3c0a commit b12f447

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/Sobol.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ end
104104
start(s::SobolSeq) = s
105105
next(s::SobolSeq, s_::SobolSeq) = (next(s), s_)
106106
done(s::SobolSeq, s_::SobolSeq) = false
107+
Base.eltype{N}(::Type{SobolSeq{N}}) = Vector{Float64}
108+
if VERSION >= v"0.5.0-dev+3305" # Julia #15123
109+
Base.iteratorsize{N}(::Type{SobolSeq{N}}) = Base.IsInfinite()
110+
Base.iteratoreltype{N}(::Type{SobolSeq{N}}) = Base.HasEltype()
111+
end
107112

108113
# Convenience wrapper for scaled Sobol sequences
109114

test/runtests.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,6 @@ for i = 1:length(N)
4646
@test_approx_eq_eps t JoeKuo[i,j] 1e-4
4747
end
4848
end
49+
50+
# issue #8
51+
@test [x[1] for x in take(Sobol.SobolSeq(1),5)] == [0.5,0.75,0.25,0.375,0.875]

0 commit comments

Comments
 (0)