LatticePathGenerator
An object to take direct products of lattice paths and filter them
__init__(self, *steps, max_len=None):
steps:Iterable[Iterable[int]]the steps to take a direct product of
@property
subtrees(self):
LLM Docstring
The per-depth lattice-path subtrees (position-tracking), generated lazily.
:returns:_the subtrees
@property
tree(self):
LLM Docstring
The final (full-depth) lattice-path tree with positions, generated lazily.
:returns:_the tree
@property
subrules(self):
LLM Docstring
The per-depth lattice-path rule trees (without position tracking), generated lazily.
:returns:_the rule subtrees
@property
rules(self):
LLM Docstring
The final (full-depth) lattice-path rule tree, generated lazily.
:returns:_the rule tree
@classmethod
generate_tree(self, rules, max_len=None, track_positions=True):
We take the combo of the specified rules, where we take successive products of 1D rules with the current set of rules following the pattern that 1. a 1D change can apply to any index in an existing rule 2. a 1D change can be appended to an existing rule
We ensure at each step that the rules remain sorted & duplicates are removed so as to keep the rule sets compact. This is done in simple python loops, because doing it with arrayops seemed harder & not worth it for a relatively cheap operation.
rules:Any:returns:_
find_paths(self, end_spots):
LLM Docstring
Return the starting steps of every lattice path that reaches one of the given end positions.
end_spots:Anythe target end position(s)
:returns:listthe qualifying starting steps
get_path(self, path):
Pulls the places one can end up after applying the path
other:Any:returns:_
find_intersections(self, other):
Finds the paths that will make self intersect with other
other:LatticePathGenerator:returns:_