Skip to content

Commit 344114d

Browse files
committed
Bypass SamplerGenerator
1 parent 388066b commit 344114d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/trajectory.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ on_insert!(t::Trajectory, n::Int) = on_insert!(t.controller, n)
104104
# out
105105
#####
106106

107-
SampleGenerator(t::Trajectory) = SampleGenerator(t.sampler, t.container)
107+
SampleGenerator(t::Trajectory) = SampleGenerator(t.sampler, t.container) #currently not in use
108108

109109
on_sample!(t::Trajectory) = on_sample!(t.controller)
110110
sample(t::Trajectory) = sample(t.sampler, t.container)
@@ -115,7 +115,14 @@ be sampled yet due to the `controller`.
115115
"""
116116
iter(t::Trajectory) = Iterators.takewhile(_ -> on_sample!(t), Iterators.cycle(SampleGenerator(t)))
117117

118-
Base.iterate(t::Trajectory, args...) = iterate(iter(t), args...)
118+
#The use of iterate(::SampleGenerator) has been suspended in v0.1.8 due to a significant drop in performance.
119+
function Base.iterate(t::Trajectory, args...)
120+
if length(t.container) > 0 && on_sample!(t)
121+
sample(t), nothing
122+
else
123+
nothing
124+
end
125+
end
119126
Base.IteratorSize(t::Trajectory) = Base.IteratorSize(iter(t))
120127

121128
Base.iterate(t::Trajectory{<:Any,<:Any,<:AsyncInsertSampleRatioController}, args...) = iterate(t.controller.ch_out, args...)

0 commit comments

Comments
 (0)