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
Add support for char as a type annotation #1806
base: devel
Are you sure you want to change the base?
Conversation
Hello! Welcome to Pyccel! Thank you very much for your contribution ❤️. I am the GitHub bot. I will help guide you through the different stages necessary to validate a review in Pyccel. If you haven't yet seen our developer docs make sure you check them out here. Amongst other things they describe the review process that we have just started. You can also get in touch with our other developers on our Pyccel Discord Server. To begin with I will give you a short checklist to make sure your pull request is complete. Please tick items off when you have completed them or determined that they are not necessary for this pull request. If you want me to run any specific tests to check out corner cases that you can't easily check on your computer, you can request this using the command Please begin by requesting your checklist using the command |
@yguclu, @EmilyBourne, @bauom, please can you check if I can trust this user. If you are happy, let me know with |
tests/pyccel/test_pyccel.py
Outdated
#------------------------------------------------------------------------------ | ||
def test_char: | ||
if __name__ == '__main__': | ||
string = np.empty((2, 5), dtype='c') |
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.
You will need to make changes in pyccel.ast.numpyext
or pyccel.ast.numpytypes
so that 'c' is recognised.
Okay I think I did the right test. I used the test_bool function as a reference. |
tests/pyccel/test_pyccel.py
Outdated
#------------------------------------------------------------------------------ | ||
def test_char(language): | ||
types = str | ||
pyccel_test("scripts/c_arrays.py", language = language, output_dtype = types) |
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.
Did you forget to commit the file scripts/c_arrays.py
?
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.
I did not because it already existed and I didn’t make any chances to it.
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.
Ah you are right sorry. It is already tested here:
pyccel/tests/pyccel/test_pyccel.py
Lines 751 to 755 in b39fe9a
def test_c_arrays(language): | |
types = [int]*15 + [float]*5 + [int]*25 + [float]* 20 * 5 + \ | |
[complex] * 3 * 10 + [complex] * 5 + [float] * 10 + [float] * 6 + \ | |
[float] * 2 * 3 + [complex] * 3 * 10 + [float] * 2 * 3 + [int] * 3 | |
pyccel_test("scripts/c_arrays.py", language=language, output_dtype=types) |
In that case it seems that you have not finished adding a test as nothing new is tested.
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.
Ok, sounds good! Do I need to do anything else for you to approve my PR?
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.
You need to:
- add a test/multiple tests that tests the things that the PR is supposed to implement (so a test which translates a file with a char type annotation)
- Ensure all the tests pass (e.g. the Codacy static analysis is currently failing)
- Interact with the bot to get and complete your checklist
- Get the example to work. Your fix is not sufficient to make the following code work:
if __name__ == '__main__':
string = np.empty((2, 5), dtype='c')
string[0] = "HELLO"
string[1] = "WORLD"
for i in range(5):
print(string[0,i], end='')
The issue you are trying to fix specifically mentions this test: pyccel/tests/internal/scripts/lapack/ex1.py and asks that the header file describing the LAPACK library be updated to use char
instead of str
where appropriate.
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.
Oh sorry I misread the previous message.
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.
Ah you are right sorry. It is already tested here:
pyccel/tests/pyccel/test_pyccel.py
Lines 751 to 755 in b39fe9a
def test_c_arrays(language): types = [int]*15 + [float]*5 + [int]*25 + [float]* 20 * 5 + \ [complex] * 3 * 10 + [complex] * 5 + [float] * 10 + [float] * 6 + \ [float] * 2 * 3 + [complex] * 3 * 10 + [float] * 2 * 3 + [int] * 3 pyccel_test("scripts/c_arrays.py", language=language, output_dtype=types) In that case it seems that you have not finished adding a test as nothing new is tested.
I am little confused on creating test functions. What test functions test type annotation? I've looked at all the functions and none of them were helping, but maybe I just missed them.
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.
Most of the functions that explicitly test type annotations are in the epyccel folder but any tests that translate files containing type annotations also test them. E.g. test_funcs tests:
https://github.com/pyccel/pyccel/blob/b39fe9a411736a833d980674b7f6380278febf0f/tests/pyccel/scripts/funcs.py
which contains type annotations
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.
Pyccel is a translator so as long as the thing you are interested in appears in the file being translated you are testing it
Still creating the test functions
Testing still not complete
Add the char annotation and created a test. Not sure if I created the test correctly.