Skip to content

Commit ea263f6

Browse files
Helmut SimonricardoV94github-actions[bot]
authored
Issue #4819, PR revision 1. (#4953)
* Issue #4819, PR revision 1. * Issue #4819, PR revision 1. * Test and release notes for Issue #4819, PR revision 1. * Update pymc3/tests/test_sampling.py Co-authored-by: Ricardo Vieira <[email protected]> * Run pre-commit Co-authored-by: Ricardo Vieira <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 7dc93e4 commit ea263f6

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

RELEASE-NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
- We now include `cloudpickle` as a required dependency, and no longer depend on `dill` (see [#4858](https://github.com/pymc-devs/pymc3/pull/4858)).
3434
- The `incomplete_beta` function in `pymc3.distributions.dist_math` was replaced by `aesara.tensor.betainc` (see [4857](https://github.com/pymc-devs/pymc3/pull/4857)).
3535
- `math.log1mexp` and `math.log1mexp_numpy` will expect negative inputs in the future. A `FutureWarning` is now raised unless `negative_input=True` is set (see [#4860](https://github.com/pymc-devs/pymc3/pull/4860)).
36+
- Attempt to iterate over MultiTrace will raise NotImplementedError
3637
- ...
3738

3839
## PyMC3 3.11.2 (14 March 2021)

pymc3/backends/base.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@ def chains(self):
313313
def report(self):
314314
return self._report
315315

316+
def __iter__(self):
317+
raise NotImplementedError
318+
316319
def __getitem__(self, idx):
317320
if isinstance(idx, slice):
318321
return self._slice(idx)

pymc3/tests/test_sampling.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,15 @@ def test_sequential_backend(self):
297297
backend = NDArray()
298298
pm.sample(10, cores=1, chains=2, trace=backend)
299299

300+
def test_exceptions(self):
301+
# Test iteration over MultiTrace NotImplementedError
302+
with pm.Model() as model:
303+
mu = pm.Normal("mu", 0.0, 1.0)
304+
a = pm.Normal("a", mu=mu, sigma=1, observed=np.array([0.5, 0.2]))
305+
trace = pm.sample(tune=0, draws=10, chains=2, return_inferencedata=False)
306+
with pytest.raises(NotImplementedError):
307+
xvars = [t["mu"] for t in trace]
308+
300309

301310
@pytest.mark.xfail(reason="Lognormal not refactored for v4")
302311
def test_sample_find_MAP_does_not_modify_start():

0 commit comments

Comments
 (0)