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

Fix lambda inliner if parameter is not referenced #1206

Merged
merged 2 commits into from
Mar 10, 2023

Conversation

tehrengruber
Copy link
Contributor

This PR fixes a small bug in the lambda inliner such that parameters which are not referenced are correctly eliminated, i.e. now

(λ(x, y) → x)(x, y)

transforms to

x

Additionally tests for the inliner were introduced (didn't exist before).

tests/next_tests/iterator_tests/test_inline_lambdas.py Outdated Show resolved Hide resolved
@pytest.mark.parametrize("opcount_preserving", [True, False])
@pytest.mark.parametrize("name,testee,expected", test_data)
def test(name, opcount_preserving, testee, expected):
if isinstance(expected, dict):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like that some tests are executed twice, but I don't see a nice way to improve on that. We could skip in the else branch, but it wouldn't be very readable, too...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While the result might be the same the test still tests different code paths opcount_preserving so they are not really executed twice.

@tehrengruber tehrengruber requested a review from havogt March 9, 2023 08:49
@tehrengruber tehrengruber merged commit b4d4760 into GridTools:main Mar 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants