From b1cbf015445f1fd0894b4fb92239921d42009767 Mon Sep 17 00:00:00 2001 From: jamesjscully Date: Wed, 2 Oct 2019 21:06:09 -0400 Subject: [PATCH 1/2] Add methods to convert Operation to Expr --- src/operations.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/operations.jl b/src/operations.jl index 45afdc78b5..31ab560c61 100644 --- a/src/operations.jl +++ b/src/operations.jl @@ -63,3 +63,9 @@ Base.convert(::Type{Operation}, x::Number) = Operation(identity, Expression[Cons Base.convert(::Type{Operation}, x::Operation) = x Base.convert(::Type{Operation}, x::Expression) = Operation(identity, Expression[x]) Operation(x) = convert(Operation, x) + +#convert to Expr +Base.Expr(op::Operation) = + op.op isa Variable ? op.op.name : Expr(:call, Symbol(op.op), Expr.(op.args)...) +Base.convert(::Type{Expr},x::Operation) = Expr(x) +end From 3bf6b6c25c85c1b6456795d7512acb88ca51620b Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Thu, 3 Oct 2019 04:45:17 -0400 Subject: [PATCH 2/2] Update operations.jl --- src/operations.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/operations.jl b/src/operations.jl index 31ab560c61..9c1146dcd0 100644 --- a/src/operations.jl +++ b/src/operations.jl @@ -68,4 +68,3 @@ Operation(x) = convert(Operation, x) Base.Expr(op::Operation) = op.op isa Variable ? op.op.name : Expr(:call, Symbol(op.op), Expr.(op.args)...) Base.convert(::Type{Expr},x::Operation) = Expr(x) -end