-
Notifications
You must be signed in to change notification settings - Fork 56
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
List support: append method #1709
Conversation
…to raise proper error message in case or dtype conflicts
Hello again! Thank you for this new pull request 🤩. Please begin by requesting your checklist using the command |
Here is your checklist. Please tick items off when you have completed them or determined that they are not necessary for this pull request:
|
f89aad4
to
cc0ace0
Compare
/bot commands |
This bot reacts to all comments which begin with
Beware: if you have never contributed to this repository and you are not a member of the Pyccel organisation, the bot will ignore all requests to run tests until permitted by a trusted reviewer. |
/bot show tests |
The following is a list of keywords which can be used to run tests. Tests in bold are run by pull requests when they are marked as ready for review:
These tests can be run with the command |
tests/errors/semantic/blocking/APPEND_LIST_INCOMPATIBLE_TYPES_3.py
Outdated
Show resolved
Hide resolved
tests/epyccel/test_epyccel_lists.py
Outdated
@pytest.mark.parametrize( 'language', [ | ||
pytest.param("c", marks = [ | ||
pytest.mark.skip(reason="append() not implemented in c"), | ||
pytest.mark.c]), | ||
pytest.param("fortran", marks = [ | ||
pytest.mark.skip(reason="append() not implemented in fortran"), | ||
pytest.mark.fortran]), | ||
pytest.param("python", marks = pytest.mark.python) | ||
] | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we not define a language
fixture in this file, rather than copying this long decorator many times?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to put xfail marks in a fixture? The xfail marks should be removed in a few weeks or months once the method is supported
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you please explain how that would be possible? I was unable to do so since I'm not that familiar with writing test files using pytest so I did in the most basic way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to put xfail marks in a fixture? The xfail marks should be removed in a few weeks or months once the method is supported
It should be possible:
@pytest.fixture( params=[
pytest.param("fortran", marks = [
pytest.mark.skip(reason="list methods not implemented in fortran"),
pytest.mark.fortran]),
pytest.param("c", marks = [
pytest.mark.skip(reason="list methods not implemented in c"),
pytest.mark.c]),
pytest.param("python", marks = pytest.mark.python)
],
scope = "module"
)
def language(request):
return request.param
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you check the refactored version please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It did work in my linux machine 🤞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good but I wonder if we should name this fixture something like language_python_ok
. At some point we will have some tests in this file which can use the existing language
fixture (without the xfails) and some which need this one (and maybe some that need one where only C or only Fortran fails)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. How about using multiple test files and move the tests from one to the other as they start passing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also possible if you have a suggestion for a good name? We may need up to 4 files:
- Passing in Python only
- Passing in C and Python
- Passing in Fortran and Python
- Passing in C, Fortran and Python
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, using four files is a bit cumbersome... We could call them
test_epyccel_lists.py
test_epyccel_lists__no_c.py
test_epyccel_lists__no_fortran.py
test_epyccel_lists__python_only.py
Another solution is using a single file, but providing a utility function which generates the correct decorators with minimum user input.
In any case I suggest that we tackle this in a future PR.
@Farouk-Echaref, @yguclu has a few questions/comments about your code. Can you go through and see if you agree with them. If not go ahead and explain why. Once you've adressed all the comments let me know with |
…ist_methods/ refactor is_homogeneous condition
/bot run linux |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job @Farouk-Echaref!
/bot run pr_tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job ! Your PR is using all the code it added/changed.
/bot show tests |
The following is a list of keywords which can be used to run tests. Tests in bold are run by pull requests when they are marked as ready for review:
These tests can be run with the command |
/bot run pyccel_lint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job ! Your PR is using all the code it added/changed.
Add support for the append() method of Python lists to the semantic stage. Add handling of that method to the Python printer. This fixes #1689.
Commit Summary
append()
method, inheriting fromPyccelInternalFunction
. The constructor ensures compatibility between the datatypes of theappend()
argument and the list for homogenous lists.ClassDef
representing aNativeHomogeneousList
. It includes a methodappend()
implemented by theListAppend
class.`get_cls_base()
function to properly check on the classtype of the containers._print_ListAppend()
to generate the appropriate python representation of theappend()
method.PythonList
) is assigned to variables created via expressions such asa = [1]
append()
method involving many scenarios where the function could be used.