Skip to content

Commit

Permalink
Use the current op to determine which etuple function to use
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rlouf authored and brandonwillard committed Sep 6, 2022
1 parent e3045d2 commit 6010add
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion etuples/dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ def apply_ExpressionTuple(rator, rands):
operator, arguments, term = rator, rands, apply


@dispatch(object)
def etuplize_fn(op):
return etuple


@dispatch(object)
def etuplize(
x,
Expand Down Expand Up @@ -140,6 +145,7 @@ def etuplize_step(
return_bad_args=return_bad_args,
convert_ConsPairs=convert_ConsPairs,
):

if isinstance(x, ExpressionTuple):
yield x
return
Expand Down Expand Up @@ -182,6 +188,6 @@ def etuplize_step(
)
et_args.append(e)

yield etuple(et_op, *et_args, evaled_obj=x)
yield etuplize_fn(op)(et_op, *et_args, evaled_obj=x)

return trampoline_eval(etuplize_step(x))

0 comments on commit 6010add

Please sign in to comment.