Skip to content

Updated test_gruntz.py #2656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 26, 2024
Merged

Conversation

anutosh491
Copy link
Collaborator

This PR introduces some changes and a case in test gruntz.py
The changes introduced are related to freeing out variables.

@anutosh491
Copy link
Collaborator Author

anutosh491 commented Apr 17, 2024

So something that doesn't work perfectly as of now is this

from lpython import S
from sympy import Symbol, E

def mmrv(e: S) -> S:
    if False:
        print(E)
    else:
        return e

def test_mrv():
    x: S = Symbol("x")
    ans: S = mmrv(x)
    print(ans)

test_mrv()

But something that does work perfectly ( a very fair workaround ) is this

from lpython import S
from sympy import Symbol, E

def mmrv(e: S) -> S:
    if False:
        var: S = E
        print(var)
    else:
        return e

def test_mrv():
    x: S = Symbol("x")
    ans: S = mmrv(x)
    print(ans)

test_mrv()

Hence the PR updates test_gruntz.py and we use assignment wherever we see vulnerabilites related to freeing out basic variables.

@anutosh491
Copy link
Collaborator Author

anutosh491 commented Apr 17, 2024

The PR also introduces a case where the base of a Pow expression might be E (basically exponential cases which is just a Pow case with base E as per symengine)

@anutosh491 anutosh491 enabled auto-merge (squash) April 26, 2024 06:54
@anutosh491 anutosh491 merged commit 4921160 into lcompilers:main Apr 26, 2024
assem2002 pushed a commit to assem2002/lpython that referenced this pull request Apr 28, 2024
assem2002 pushed a commit to assem2002/lpython that referenced this pull request Apr 28, 2024
@anutosh491 anutosh491 deleted the update_gruntz.py branch June 13, 2024 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants