Skip to content

Commit 89558c2

Browse files
committed
Refactor code
1 parent ccf5c93 commit 89558c2

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

pymc3/step_methods/hmc/base_hmc.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,23 +169,19 @@ def warnings(self):
169169
warnings = self._warnings[:]
170170

171171
# Generate a global warning for divergences
172+
message = ''
172173
n_divs = self._num_divs_sample
173174
if n_divs and self._samples_after_tune == n_divs:
174175
message = ('The chain contains only diverging samples. The model '
175176
'is probably misspecified.')
176-
warning = SamplerWarning(
177-
WarningType.DIVERGENCES, message, 'error', None, None, None)
178-
warnings.append(warning)
179177
elif n_divs == 1:
180178
message = ('There was 1 divergence after tuning. Increase '
181179
'`target_accept` or reparameterize.')
182-
warning = SamplerWarning(
183-
WarningType.DIVERGENCES, message, 'error', None, None, None)
184-
warnings.append(warning)
185180
elif n_divs > 1:
186181
message = ('There were %s divergences after tuning. Increase '
187-
'`target_accept` or reparameterize.'
188-
% n_divs)
182+
'`target_accept` or reparameterize.' % n_divs)
183+
184+
if message:
189185
warning = SamplerWarning(
190186
WarningType.DIVERGENCES, message, 'error', None, None, None)
191187
warnings.append(warning)

0 commit comments

Comments
 (0)