JuliaMath / JuliaMath/Sobol.jl

iterator interface

Open
#8 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
82
Forks
17
PR merge metrics
No merged PRs in 30d

Description

Thanks for this great library, I find it very useful. However, I am not sure that the library supports the iteration interface of Julia. Eg `Sobol.SobolSeq` returns not an iterator, but an iterator _and a state_. So, for example,

``` julia
import Sobol

function collect_take(iter, n)
v = Vector{Float64}(0)
for (i, x) in enumerate(iter)
push!(v, x[1])
if (i >= n)
break
end
end
v
end
double_take(iter, n) = vcat(collect_take(iter,5), collect_take(iter,5))
double_take(Sobol.SobolSeq(1), 5)
```

returns the first 10 elements (instead of the first 5, twice). Cf, for example,

``` julia
double_take(countfrom(1),5)
```

Also, idioms like

``` julia
[x[1] for x in take(Sobol.SobolSeq(1),5)]
```

don't work.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.