File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change 20
20
pass
21
21
22
22
23
- __version__ = "0.1.1 "
23
+ __version__ = "0.1.2 "
Original file line number Diff line number Diff line change @@ -188,9 +188,13 @@ def to_inferencedata(self, **kwargs) -> InferenceData:
188
188
posterior = collections .defaultdict (list )
189
189
sample_stats = collections .defaultdict (list )
190
190
for c , chain in enumerate (chains ):
191
+ # Every retrieved array is shortened to the previously determined chain length.
192
+ # This is needed for database backends which may get inserts inbetween.
193
+ clen = chain_lengths [chain .cid ]
194
+
191
195
# Obtain a mask by which draws can be split into warmup/posterior
192
196
if "tune" in chain .sample_stats :
193
- tune = chain .get_stats ("tune" ).astype (bool )
197
+ tune = chain .get_stats ("tune" )[: clen ] .astype (bool )
194
198
else :
195
199
if c == 0 :
196
200
_log .warning (
@@ -200,12 +204,12 @@ def to_inferencedata(self, **kwargs) -> InferenceData:
200
204
201
205
# Split all variables draws into warmup/posterior
202
206
for var in variables :
203
- draws = chain .get_draws (var .name )
207
+ draws = chain .get_draws (var .name )[: clen ]
204
208
warmup_posterior [var .name ].append (draws [tune ])
205
209
posterior [var .name ].append (draws [~ tune ])
206
210
# Same for sample stats
207
211
for svar in self .meta .sample_stats :
208
- stats = chain .get_stats (svar .name )
212
+ stats = chain .get_stats (svar .name )[: clen ]
209
213
warmup_sample_stats [svar .name ].append (stats [tune ])
210
214
sample_stats [svar .name ].append (stats [~ tune ])
211
215
You can’t perform that action at this time.
0 commit comments