Skip to content

Commit

Permalink
Remove unused _ancestors method
Browse files Browse the repository at this point in the history
New Breadth-first search version of _get_ancestors no longer uses it.
Also added some type annotations to clarify.
  • Loading branch information
rpgoldman committed May 5, 2019
1 parent 8981c7e commit 2e6e44d
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions pymc3/model_graph.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import itertools
from collections import deque
from typing import Iterator, Optional
from typing import Iterator, Optional, MutableSet

from theano.gof.graph import ancestors, stack_search
from theano.compile import SharedVariable
Expand Down Expand Up @@ -42,19 +42,15 @@ def get_deterministics(self, var):
deterministics.append(v)
return deterministics

def _ancestors(self, var, func, blockers=None):
"""Get ancestors of a function that are also named PyMC3 variables"""
return set([j for j in ancestors([func], blockers=blockers) if j in self.var_list and j != var])

def _get_ancestors(self, var, func):
def _get_ancestors(self, var, func) -> MutableSet[RV]:
"""Get all ancestors of a function, doing some accounting for deterministics.
"""

# this contains all of the variables in the model EXCEPT var...
vars: List[var] = set(self.var_list)
vars: MutableSet[RV] = set(self.var_list)
vars.remove(var)

blockers = set()
blockers: MutableSet[RV] = set()
retval = set()
def _expand(node) -> Optional[Iterator[Tensor]]:
if node in blockers:
Expand Down

0 comments on commit 2e6e44d

Please sign in to comment.