Skip to content

Commit 2f77f99

Browse files
committed
Fix bug: 0 divergences are possible!
1 parent 0e32e54 commit 2f77f99

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

pymc3/step_methods/hmc/base_hmc.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,17 +173,22 @@ def warnings(self):
173173
if n_divs and self._samples_after_tune == n_divs:
174174
message = ('The chain contains only diverging samples. The model '
175175
'is probably misspecified.')
176+
warning = SamplerWarning(
177+
WarningType.DIVERGENCES, message, 'error', None, None, None)
178+
warnings.append(warning)
176179
elif n_divs == 1:
177180
message = ('There was 1 divergence after tuning. Increase '
178181
'`target_accept` or reparameterize.')
182+
warning = SamplerWarning(
183+
WarningType.DIVERGENCES, message, 'error', None, None, None)
184+
warnings.append(warning)
179185
elif n_divs > 1:
180186
message = ('There were %s divergences after tuning. Increase '
181187
'`target_accept` or reparameterize.'
182188
% n_divs)
189+
warning = SamplerWarning(
190+
WarningType.DIVERGENCES, message, 'error', None, None, None)
191+
warnings.append(warning)
183192

184-
warning = SamplerWarning(
185-
WarningType.DIVERGENCES, message, 'error', None, None, None)
186-
warnings.append(warning)
187193
warnings.extend(self.step_adapt.warnings())
188-
189194
return warnings

0 commit comments

Comments
 (0)