Skip to content

Commit 306155a

Browse files
authored
Merge pull request #3466 from lucianopaz/iss3465
Remove variable annotations
2 parents bcf5637 + e080cae commit 306155a

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

RELEASE-NOTES.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
- 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.
1313

1414
### Maintenance
15-
- 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.
1615
- All occurances of `sd` as a parameter name have been renamed to `sigma`. `sd` will continue to function for backwards compatibility.
1716
- Made `BrokenPipeError` for parallel sampling more verbose on Windows.
1817
- 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 @@
3837
- 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.
3938
- 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`.
4039
- 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()`.
40+
- 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.
41+
- Removed variable annotations from `model_graph` but left type hints (Fix for #3465). This means that we support `python>=3.5.4`.
4142

4243
### Deprecations
4344

pymc3/model_graph.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import itertools
21
from collections import deque
32
from typing import Iterator, Optional, MutableSet
43

@@ -14,17 +13,6 @@
1413
RV = Tensor
1514

1615

17-
def powerset(iterable):
18-
"""All *nonempty* subsets of an iterable.
19-
20-
From itertools docs.
21-
22-
powerset([1,2,3]) --> (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)
23-
"""
24-
s = list(iterable)
25-
return itertools.chain.from_iterable(itertools.combinations(s, r) for r in range(1, len(s)+1))
26-
27-
2816
class ModelGraph:
2917
def __init__(self, model):
3018
self.model = model
@@ -47,10 +35,10 @@ def _get_ancestors(self, var, func) -> MutableSet[RV]:
4735
"""
4836

4937
# this contains all of the variables in the model EXCEPT var...
50-
vars: MutableSet[RV] = set(self.var_list)
38+
vars = set(self.var_list)
5139
vars.remove(var)
52-
53-
blockers: MutableSet[RV] = set()
40+
41+
blockers = set()
5442
retval = set()
5543
def _expand(node) -> Optional[Iterator[Tensor]]:
5644
if node in blockers:

0 commit comments

Comments
 (0)