-
Notifications
You must be signed in to change notification settings - Fork 158
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 unsigned integer bitnot #2061
Conversation
In the commit lpython.py: Use numpy functions, I replaced custom functions with Please share if it is fine. |
Ready. |
I would only depend on CPython for now by default. Of course if you use NumPy then you need NumPy, but I would not require it if you don't use NumPy. |
I think this looks great. Do you mind splitting the assert improvement into a separate PR? It will be much easier to review. |
Ready. |
integration_tests/bindpy_01.py
Outdated
pass | ||
|
||
@pythoncall(module = "bindpy_01_module") | ||
def multiply_ints(a: i32, b: i64, c: u32, d: u64) -> i64: | ||
def multiply_ints(a: u32, b: u32, c: u32, d: u32) -> u64: |
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.
Are the signed integers tested somewhere? It seems we are now only testing unsigned integers, but we need to test both signed and unsigned.
I think this PR is great now, except that it seems the signed integer tests were removed --- if you can test both signed and unsigned, then we can merge it. |
Implement operations on UnsignedInteger for CPython
TEST: Add test for unsigned ints in bindpy_01.py
Test taken from lcompilers#2054
@@ -1,11 +1,19 @@ | |||
from lpython import i32, i64, u32, u64, f32, f64, pythoncall | |||
|
|||
@pythoncall(module = "bindpy_01_module") | |||
def add_ints(a: i32, b: i64, c: u32, d: u64) -> i64: | |||
def add_ints(a: i32, b: i32, c: i32, d: i32) -> i64: |
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 i64 not tested now?
pass | ||
|
||
@pythoncall(module = "bindpy_01_module") | ||
def add_unsigned_ints(a: u32, b: u32, c: u32, d: u32) -> u64: |
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.
Let's test u64 too.
I would say in this PR make sure all previous tests are left, and just add some unsigned tests. Then in the next PR, let's test rigorously i8, i16, i32, i64 and u8, u16, u32, u64 to make sure they all work. |
Yes, These tests were added to test initial support of These types will be tested thoroughly as we add more support for CPython-Interop (For example the pass at #2050). When I added this test initially, I kept the test case slightly less robust (and even slightly odd, for example multiplying/adding variables of different types together) so that we can have some freedom (or thinking/discussion opportunities) in the design/structure of CPython Interop. We are needing to update this test Currently, the updated test tests integers (only Please share what we should do. Any approach works for me. |
Sure we can do this. PS: Or shall we add more tests once we have the pass? |
I think this is fine. We should now make sure all combinations are tested. |
We made a mistake here. The UnsignedIntegerBitNot wraps around, and thus does NOT correspond do the CPython's We need to create a new intrinsic function |
fixes #2054