Skip to content

Commit 9f3bba0

Browse files
committed
Remove unused _ancestors method
New Breadth-first search version of _get_ancestors no longer uses it. Also added some type annotations to clarify.
1 parent 8981c7e commit 9f3bba0

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

pymc3/model_graph.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import itertools
22
from collections import deque
3-
from typing import Iterator, Optional
3+
from typing import Iterator, Optional, MutableSet
44

5-
from theano.gof.graph import ancestors, stack_search
5+
from theano.gof.graph import stack_search
66
from theano.compile import SharedVariable
77
from theano.tensor import Tensor
88

@@ -42,19 +42,15 @@ def get_deterministics(self, var):
4242
deterministics.append(v)
4343
return deterministics
4444

45-
def _ancestors(self, var, func, blockers=None):
46-
"""Get ancestors of a function that are also named PyMC3 variables"""
47-
return set([j for j in ancestors([func], blockers=blockers) if j in self.var_list and j != var])
48-
49-
def _get_ancestors(self, var, func):
45+
def _get_ancestors(self, var, func) -> MutableSet[RV]:
5046
"""Get all ancestors of a function, doing some accounting for deterministics.
5147
"""
5248

5349
# this contains all of the variables in the model EXCEPT var...
54-
vars: List[var] = set(self.var_list)
50+
vars: MutableSet[RV] = set(self.var_list)
5551
vars.remove(var)
5652

57-
blockers = set()
53+
blockers: MutableSet[RV] = set()
5854
retval = set()
5955
def _expand(node) -> Optional[Iterator[Tensor]]:
6056
if node in blockers:

0 commit comments

Comments
 (0)