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

Add isspace API in str #2373

Merged
merged 18 commits into from
Oct 8, 2023
Merged

Conversation

Agent-Hellboy
Copy link
Contributor

@Agent-Hellboy Agent-Hellboy commented Oct 8, 2023

fixes #2375

@Agent-Hellboy
Copy link
Contributor Author

is the ci check disabled because of the conflicting files?
I forgot to do a rebase before running ./run_test.py -u what should I do?

@Thirumalai-Shaktivel
Copy link
Collaborator

is the ci check disabled because of the conflicting files?

Yup!

I forgot to do a rebase before running ./run_test.py -u what should I do?

$ git checkout main 
$ git pull lpython main # where `lpython` is the remote name of the lpython main repository
$ git checkout add_isspace_api
$ git merge main
   # resolve conflicts if any
$ git reset main
   # Now, all the changes you made will be ready to be staged
$ git add . # `.` represents the file you want to commit
$ git commit -m ".. message" # Commit all the files 
$ git push -f origin add_isspace_api # where `origin` is the remote name for your lpython forked repository

For more details on merging and rebasing, go through the page: https://github.com/lcompilers/lpython/blob/main/doc/src/rebasing.md

@certik certik marked this pull request as draft October 8, 2023 06:53
@Agent-Hellboy
Copy link
Contributor Author

Thanks, @Thirumalai-Shaktivel, what should I do for the below error?

compiler_tester.tester.RunException: Testing with reference output failed.
complex1.py * asr
The JSON metadata differs against reference results
Reference JSON: tests/reference/asr-complex1-f26c460.json
Output JSON:    tests/output/asr-complex1-f26c460.json
Omitting 6 identical items
Differing items:
{'returncode': 0} != {'returncode': 2}
{'stderr_hash': None} != {'stderr_hash': '850f4cbe87b0a7ae81[38](https://github.com/lcompilers/lpython/actions/runs/6446076488/job/17500797616?pr=2373#step:6:39)fbfb71f94b82843abf09e50752159f900292'}
{'stdout_hash': 'd2492faf2c4817c79e63e63c41265783d5cc209b149ea270194804[40](https://github.com/lcompilers/lpython/actions/runs/6446076488/job/17500797616?pr=2373#step:6:41)'} != {'stdout_hash': None}
{'stderr': None} != {'stderr': 'asr-complex1-f26c[46](https://github.com/lcompilers/lpython/actions/runs/6446076488/job/17500797616?pr=2373#step:6:47)0.stderr'}
{'stdout': 'asr-complex1-f26c460.stdout'} != {'stdout': None}No reference stdout_hash available for complex1.py

Do reference tests get generated on the fly, do I need to delete all reference tests and then run ./run_tests.py -u?

@Thirumalai-Shaktivel
Copy link
Collaborator

Don't do it all the time, but for this PR you can do rm tests/reference/* and then do ./run_tests.py -u

@Thirumalai-Shaktivel
Copy link
Collaborator

I'm sorry, I forgot to add the following command above:
After committing the changes, you have to make a clean build and then update tests,

$ git clean -dfx
$ ./build.sh
$ ./run_tests.py # Use `-u` to update tests.

@@ -0,0 +1,17 @@
warning: The module 'numpy' located in $DIR/src/bin/../runtime/lpython_intrinsic_numpy.py cannot be loaded
--> tests/../integration_tests/array_01_decl.py:2:1
Copy link
Collaborator

@Thirumalai-Shaktivel Thirumalai-Shaktivel Oct 8, 2023

Choose a reason for hiding this comment

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

All the newly created *.stderr files needs to be removed.

For that,

you can do rm tests/reference/* and then do ./run_tests.py -u

Copy link
Collaborator

@Thirumalai-Shaktivel Thirumalai-Shaktivel left a comment

Choose a reason for hiding this comment

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

Looks great, thank you!

@Shaikh-Ubaid
Copy link
Collaborator

@Agent-Hellboy The CI seems to fail currently.

@Agent-Hellboy
Copy link
Contributor Author

Agent-Hellboy commented Oct 8, 2023

@Agent-Hellboy The CI seems to fail currently.

yes,

/home/runner/work/lpython/lpython/integration_tests/_lpython-tmp-test-c/test_str_attributes.c:117:6: warning: conflicting types for built-in function ‘isspace’; expected ‘int(int)’ [-Wbuiltin-declaration-mismatch]
  117 | void isspace();
      |      ^~~~~~~
/home/runner/work/lpython/lpython/integration_tests/_lpython-tmp-test-c/test_str_attributes.c:9:1: note: ‘isspace’ is declared in header ‘<ctype.h>’
    8 | #include <lfortran_intrinsics.h>
  +++ |+#include <ctype.h>
    9 | 
/home/runner/work/lpython/lpython/integration_tests/_lpython-tmp-test-c/test_str_attributes.c: In function ‘__lpython_overloaded_0___lpython_str_isspace’:
/home/runner/work/lpython/lpython/integration_tests/_lpython-tmp-test-c/test_str_attributes.c:1991:167: error: \u000b is not a valid universal character
 1991 |         if (strcmp(ch, " ")  !=  0 && strcmp(ch, "\t")  !=  0 && strcmp(ch, "\n")  !=  0 && strcmp(ch, "\r")  !=  0 && strcmp(ch, "\\f")  !=  0 && strcmp(ch, "\u000b")  !=  0) {
      |     
      

is one of the backend treating \v as \u000b ?

@Shaikh-Ubaid
Copy link
Collaborator

Shaikh-Ubaid commented Oct 8, 2023

is one of the backend treating \v to \u000b ?

It is the C backend. You can tell it from _lpython-tmp-test-c (the c at the end). The specific test that fails is integration_tests/test_str_attributes.py. Try looking into the backend asr_to_c.cpp or asr_to_c_cpp.cpp. You can simply test this specific test case using ./src/bin/lpython integration_tests/test_str_attributes.py --backend=c.

You can construct a simple/minimum example using the \v and see what the C backend generates for it. Then using this simple example, we can debug the C backend.

@Agent-Hellboy
Copy link
Contributor Author

You can construct a simple/minimum example using the \v and see what the C backend generates for it. Then using this simple example, we can debug the C backend.

The \v escape sequence is part of the standard C escape sequences
https://en.wikipedia.org/wiki/Escape_sequences_in_C
don't know why it is converting \v to \u000b

@Agent-Hellboy
Copy link
Contributor Author

I have used '\x0B'for now, created an issue #2375

Agent-Hellboy and others added 2 commits October 8, 2023 14:00
Co-authored-by: Shaikh Ubaid <shaikhubaid769@gmail.com>
@Agent-Hellboy Agent-Hellboy marked this pull request as ready for review October 8, 2023 09:06
Copy link
Contributor

@certik certik left a comment

Choose a reason for hiding this comment

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

I think that this is good, I left some comments.

src/lpython/semantics/python_ast_to_asr.cpp Outdated Show resolved Hide resolved
src/lpython/semantics/python_ast_to_asr.cpp Outdated Show resolved Hide resolved
src/lpython/semantics/python_ast_to_asr.cpp Outdated Show resolved Hide resolved
Co-authored-by: Ondřej Čertík <ondrej@certik.us>
Agent-Hellboy and others added 2 commits October 8, 2023 17:32
Co-authored-by: Ondřej Čertík <ondrej@certik.us>
Co-authored-by: Ondřej Čertík <ondrej@certik.us>
@@ -858,6 +858,15 @@ def _lpython_str_isascii(s: str) -> bool:
return False
return True

@overload
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this work:

Suggested change
@overload

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know what overload does. from the code, it seems it adds attributes to it.

Copy link
Contributor

Choose a reason for hiding this comment

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

The @overload allows you to use the same function name with different arguments like int and float. In this case there is only one function, so overload is not needed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yup, we have to remove @overload for many functions. I got confused with the actual meaning of overload, as it was used everywhere.

Agent-Hellboy and others added 2 commits October 8, 2023 18:24
Co-authored-by: Ondřej Čertík <ondrej@certik.us>
Co-authored-by: Ondřej Čertík <ondrej@certik.us>
@certik
Copy link
Contributor

certik commented Oct 8, 2023

@Agent-Hellboy why don't you fix the comment per my post above and then we can merge it.

@Agent-Hellboy
Copy link
Contributor Author

@Agent-Hellboy why don't you fix the comment per my post above and then we can merge it.

sure

@certik certik enabled auto-merge (squash) October 8, 2023 13:01
@certik certik merged commit 87e7caa into lcompilers:main Oct 8, 2023
13 checks passed
Copy link
Collaborator

@Shaikh-Ubaid Shaikh-Ubaid left a comment

Choose a reason for hiding this comment

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

Amazing work @Agent-Hellboy! Thank you so much for this!

Agent-Hellboy added a commit to Agent-Hellboy/lpython that referenced this pull request Oct 9, 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.

why \v is getting converted into \u000b during asr_to_c conversion
4 participants