Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Fixed LHS auto typing conversion for Expr arithmetic (#146)
Browse files Browse the repository at this point in the history
Now Expr arithmetic doesn't require LHS to be Expr but can be ToExpr as
well.

Thanks to Sandro for pointing out this error.
  • Loading branch information
qwang98 authored Oct 16, 2023
1 parent 8e0b667 commit c527f5e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "chiquito"
version = "0.1.2023092400"
version = "0.1.2023101100"
edition = "2021"
license = "MIT OR Apache-2.0"
authors = ["Leo Lara <[email protected]>"]
Expand Down
3 changes: 3 additions & 0 deletions src/frontend/python/chiquito/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,23 @@ def __add__(self: Expr, rhs: ToExpr) -> Sum:
return Sum([self, rhs])

def __radd__(self: Expr, lhs: ToExpr) -> Sum:
lhs = to_expr(lhs)
return Expr.__add__(lhs, self)

def __sub__(self: Expr, rhs: ToExpr) -> Sum:
rhs = to_expr(rhs)
return Sum([self, Neg(rhs)])

def __rsub__(self: Expr, lhs: ToExpr) -> Sum:
lhs = to_expr(lhs)
return Expr.__sub__(lhs, self)

def __mul__(self: Expr, rhs: ToExpr) -> Mul:
rhs = to_expr(rhs)
return Mul([self, rhs])

def __rmul__(self: Expr, lhs: ToExpr) -> Mul:
lhs = to_expr(lhs)
return Expr.__mul__(lhs, self)

def __pow__(self: Expr, rhs: int) -> Pow:
Expand Down

0 comments on commit c527f5e

Please sign in to comment.