Skip to content

Commit 2c8f3c3

Browse files
Fix warning always being printed (#5286)
1 parent 14c4f39 commit 2c8f3c3

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

pymc/backends/arviz.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -386,12 +386,13 @@ def translate_posterior_predictive_dict_to_xarray(self, dct, kind) -> xr.Dataset
386386
else:
387387
data[k] = np.expand_dims(ary, 0)
388388
warning_vars.append(k)
389-
warnings.warn(
390-
f"The shape of variables {', '.join(warning_vars)} in {kind} group is not compatible "
391-
"with number of chains and draws. The automatic dimension naming might not have worked. "
392-
"This can also mean that some draws or even whole chains are not represented.",
393-
UserWarning,
394-
)
389+
if warning_vars:
390+
warnings.warn(
391+
f"The shape of variables {', '.join(warning_vars)} in {kind} group is not compatible "
392+
"with number of chains and draws. The automatic dimension naming might not have worked. "
393+
"This can also mean that some draws or even whole chains are not represented.",
394+
UserWarning,
395+
)
395396
return dict_to_dataset(data, library=pymc, coords=self.coords, dims=self.dims)
396397

397398
@requires(["posterior_predictive"])

0 commit comments

Comments
 (0)