diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 14f98a2a76..9a5d1c0c6a 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -12,7 +12,6 @@ - Used `numpy.vectorize` in `distributions.distribution._compile_theano_function`. This enables `sample_prior_predictive` and `sample_posterior_predictive` to ask for tuples of samples instead of just integers. This fixes issue #3422. ### Maintenance -- Fixed an issue in `model_graph` that caused construction of the graph of the model for rendering to hang: replaced a search over the powerset of the nodes with a breadth-first search over the nodes. Fix for #3458. - All occurances of `sd` as a parameter name have been renamed to `sigma`. `sd` will continue to function for backwards compatibility. - Made `BrokenPipeError` for parallel sampling more verbose on Windows. - Added the `broadcast_distribution_samples` function that helps broadcasting arrays of drawn samples, taking into account the requested `size` and the inferred distribution shape. This sometimes is needed by distributions that call several `rvs` separately within their `random` method, such as the `ZeroInflatedPoisson` (Fix issue #3310). @@ -38,6 +37,8 @@ - Fixed the `Multinomial.random` and `Multinomial.random_` methods to make them compatible with the new `generate_samples` function. In the process, a bug of the `Multinomial.random_` shape handling was discovered and fixed. - Fixed a defect found in `Bound.random` where the `point` dictionary was passed to `generate_samples` as an `arg` instead of in `not_broadcast_kwargs`. - Fixed a defect found in `Bound.random_` where `total_size` could end up as a `float64` instead of being an integer if given `size=tuple()`. +- Fixed an issue in `model_graph` that caused construction of the graph of the model for rendering to hang: replaced a search over the powerset of the nodes with a breadth-first search over the nodes. Fix for #3458. +- Removed variable annotations from `model_graph` but left type hints (Fix for #3465). This means that we support `python>=3.5.4`. ### Deprecations diff --git a/pymc3/model_graph.py b/pymc3/model_graph.py index 0ca440c521..512b529ae5 100644 --- a/pymc3/model_graph.py +++ b/pymc3/model_graph.py @@ -1,4 +1,3 @@ -import itertools from collections import deque from typing import Iterator, Optional, MutableSet @@ -14,17 +13,6 @@ RV = Tensor -def powerset(iterable): - """All *nonempty* subsets of an iterable. - - From itertools docs. - - powerset([1,2,3]) --> (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3) - """ - s = list(iterable) - return itertools.chain.from_iterable(itertools.combinations(s, r) for r in range(1, len(s)+1)) - - class ModelGraph: def __init__(self, model): self.model = model @@ -47,10 +35,10 @@ def _get_ancestors(self, var, func) -> MutableSet[RV]: """ # this contains all of the variables in the model EXCEPT var... - vars: MutableSet[RV] = set(self.var_list) + vars = set(self.var_list) vars.remove(var) - - blockers: MutableSet[RV] = set() + + blockers = set() retval = set() def _expand(node) -> Optional[Iterator[Tensor]]: if node in blockers: