Skip to content

Commit 6010add

Browse files
rloufbrandonwillard
authored andcommitted
Use the current op to determine which etuple function to use
The first argument passed to `etuple` determines which of the registered functions is called. The first argument is generally an `ExpressionTuple`, the etuplized version of the operator. However, when using subclasses of `ExpressionTuple` to customize evaluation, we want `etuple` to depend on the current operator and not its etuplized version.
1 parent e3045d2 commit 6010add

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

etuples/dispatch.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ def apply_ExpressionTuple(rator, rands):
101101
operator, arguments, term = rator, rands, apply
102102

103103

104+
@dispatch(object)
105+
def etuplize_fn(op):
106+
return etuple
107+
108+
104109
@dispatch(object)
105110
def etuplize(
106111
x,
@@ -140,6 +145,7 @@ def etuplize_step(
140145
return_bad_args=return_bad_args,
141146
convert_ConsPairs=convert_ConsPairs,
142147
):
148+
143149
if isinstance(x, ExpressionTuple):
144150
yield x
145151
return
@@ -182,6 +188,6 @@ def etuplize_step(
182188
)
183189
et_args.append(e)
184190

185-
yield etuple(et_op, *et_args, evaled_obj=x)
191+
yield etuplize_fn(op)(et_op, *et_args, evaled_obj=x)
186192

187193
return trampoline_eval(etuplize_step(x))

0 commit comments

Comments
 (0)