Skip to content

Commit

Permalink
add iterator traits for #8
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengj committed Oct 12, 2016
1 parent 29d3c0a commit b12f447
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Sobol.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ end
start(s::SobolSeq) = s
next(s::SobolSeq, s_::SobolSeq) = (next(s), s_)
done(s::SobolSeq, s_::SobolSeq) = false
Base.eltype{N}(::Type{SobolSeq{N}}) = Vector{Float64}
if VERSION >= v"0.5.0-dev+3305" # Julia #15123
Base.iteratorsize{N}(::Type{SobolSeq{N}}) = Base.IsInfinite()
Base.iteratoreltype{N}(::Type{SobolSeq{N}}) = Base.HasEltype()
end

# Convenience wrapper for scaled Sobol sequences

Expand Down
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ for i = 1:length(N)
@test_approx_eq_eps t JoeKuo[i,j] 1e-4
end
end

# issue #8
@test [x[1] for x in take(Sobol.SobolSeq(1),5)] == [0.5,0.75,0.25,0.375,0.875]

0 comments on commit b12f447

Please sign in to comment.