-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for handling chaining of Symbolic operators and printin…
…g without assignment . (#2051)
- Loading branch information
1 parent
180ba71
commit dc3510b
Showing
5 changed files
with
176 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from sympy import Symbol, pi, S | ||
from lpython import S | ||
|
||
def test_chained_operations(): | ||
x: S = Symbol('x') | ||
y: S = Symbol('y') | ||
z: S = Symbol('z') | ||
a: S = Symbol('a') | ||
b: S = Symbol('b') | ||
|
||
# Chained Operations | ||
w: S = (x + y) * ((a - b) / (pi + z)) | ||
result: S = (w ** S(2) - pi) + S(3) | ||
|
||
# Print Statements | ||
print(result) | ||
# Expected: 3 + (a - b)**2*(x + y)**2/(z + pi)**2 - pi | ||
|
||
# Additional Variables | ||
c: S = Symbol('c') | ||
d: S = Symbol('d') | ||
e: S = Symbol('e') | ||
f: S = Symbol('f') | ||
|
||
# Chained Operations with Additional Variables | ||
x = (c * d + e) / f | ||
y = (x - S(10)) * (pi + S(5)) | ||
z = y ** (S(2) / (f + d)) | ||
result = (z + e) * (a - b) | ||
|
||
# Print Statements | ||
print(result) | ||
# Expected: (a - b)*(e + ((5 + pi)*(-10 + (e + c*d)/f))**(2/(d + f))) | ||
print(x) | ||
# Expected: (e + c*d)/f | ||
print(y) | ||
# Expected: (5 + pi)*(-10 + (e + c*d)/f) | ||
print(z) | ||
# Expected: ((5 + pi)*(-10 + (e + c*d)/f))**(2/(d + f)) | ||
|
||
test_chained_operations() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters