Fused ``Blockwise`` expression A ``Fused`` corresponds to the fusion of multiple ``Blockwise`` expressions into a single ``Expr`` object. Before graph-materialization time, the behavior of this object should be identical to that of the first element of ``Fused.exprs`` (i.e. the
| 3785 | |
| 3786 | |
| 3787 | class Fused(Blockwise): |
| 3788 | """Fused ``Blockwise`` expression |
| 3789 | |
| 3790 | A ``Fused`` corresponds to the fusion of multiple |
| 3791 | ``Blockwise`` expressions into a single ``Expr`` object. |
| 3792 | Before graph-materialization time, the behavior of this |
| 3793 | object should be identical to that of the first element |
| 3794 | of ``Fused.exprs`` (i.e. the top-most expression in |
| 3795 | the fused group). |
| 3796 | |
| 3797 | Parameters |
| 3798 | ---------- |
| 3799 | exprs : List[Expr] |
| 3800 | Group of original ``Expr`` objects being fused together. |
| 3801 | *dependencies: |
| 3802 | List of external ``Expr`` dependencies. External-``Expr`` |
| 3803 | dependencies correspond to any ``Expr`` operand that is |
| 3804 | not already included in ``exprs``. Note that these |
| 3805 | dependencies should be defined in the order of the ``Expr`` |
| 3806 | objects that require them (in ``exprs``). These |
| 3807 | dependencies do not include literal operands, because those |
| 3808 | arguments should already be captured in the fused subgraphs. |
| 3809 | """ |
| 3810 | |
| 3811 | _parameters = ["exprs"] |
| 3812 | |
| 3813 | @functools.cached_property |
| 3814 | def _meta(self): |
| 3815 | return self.exprs[0]._meta |
| 3816 | |
| 3817 | def _tree_repr_lines(self, indent=0, recursive=True): |
| 3818 | header = f"Fused({self._name[-5:]}):" |
| 3819 | if not recursive: |
| 3820 | return [header] |
| 3821 | |
| 3822 | seen = set() |
| 3823 | lines = [] |
| 3824 | stack = [(self.exprs[0], 2)] |
| 3825 | fused_group = [_expr._name for _expr in self.exprs] |
| 3826 | dependencies = {dep._name: dep for dep in self.dependencies()} |
| 3827 | while stack: |
| 3828 | expr, _indent = stack.pop() |
| 3829 | |
| 3830 | if expr._name in seen: |
| 3831 | continue |
| 3832 | seen.add(expr._name) |
| 3833 | |
| 3834 | line = expr._tree_repr_lines(_indent, recursive=False)[0] |
| 3835 | lines.append(line.replace(" ", "|", 1)) |
| 3836 | for dep in expr.dependencies(): |
| 3837 | if dep._name in fused_group: |
| 3838 | stack.append((dep, _indent + 2)) |
| 3839 | elif dep._name in dependencies: |
| 3840 | dependencies.pop(dep._name) |
| 3841 | lines.extend(dep._tree_repr_lines(_indent + 2)) |
| 3842 | |
| 3843 | for dep in dependencies.values(): |
| 3844 | lines.extend(dep._tree_repr_lines(2)) |
no outgoing calls
no test coverage detected
searching dependent graphs…