Skip to content
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

Fixing symbolic compare for test_gruntz.py #2488

Merged
merged 2 commits into from
Feb 8, 2024

Conversation

anutosh491
Copy link
Collaborator

The next few cases for test_gruntz.py would involve cases where symbolic compare should work correctly
For eg check case 2 ( we need if e == x working for the same)

def mmrv(e: S, x: S) -> list[S]:
    if not e.has(x):
        empty_list: list[S] = []
        return empty_list
    elif e == x:
        list1: list[S] = [x]
        return list1
    else:
        raise

def test_mrv():
    # Case 1
    x: S = Symbol("x")
    y: S = Symbol("y")
    ans1: list[S] = mmrv(y, x)
    print(ans1)
    assert len(ans1) == 0

    # Case 2
    ans2: list[S] = mmrv(x, x)
    ele1: S = ans2[0]
    print(ele1)
    assert len(ans2) == 1

test_mrv()

@anutosh491
Copy link
Collaborator Author

anutosh491 commented Feb 6, 2024

So the plan would be

@anutosh491
Copy link
Collaborator Author

from lpython import S
from sympy import Symbol, pi, Add, Mul, Pow, E, log

def mmrv(e: S, x: S) -> set[S]:
    if not e.has(x):
        empty_set: set[S]
        return empty_set
    elif e == x:
        set1: set[S] = {x}
        return set1
    elif e.func == Mul or e.func == Add:
        # TODO
    elif e.func == Pow and e.args[0] != E:
        # TODO
    elif e.func == log:
        arg0: S = e.args[0]
        set4: set[S] = mmrv(arg0, x)
        set5: set[S]
        for i in set4:
            ele: S = log(i)
            set5.add(ele)
        return set5
    elif e.func == Pow and e.args[0] == E:
        arg1: S = e.args[1]
        if arg1.func == log:
            arg2 = arg1.args[0]
            return mmrv(arg2, x)
        # TODO
    else:
        raise

def test_mmrv():
    x: S = Symbol("x")
    y: S = Symbol("y")
    ans: set[S] = mmrv(y, x)

test_mmrv()

@anutosh491
Copy link
Collaborator Author

Ready

@certik certik merged commit 0b9f575 into lcompilers:main Feb 8, 2024
12 of 13 checks passed
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.

None yet

2 participants