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 casting from int enums #7581
Conversation
gpuci run tests |
Can you add a test for the failing case please? |
For the location of the test, it could go in |
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.
Thanks for adding the tests. I suggested some changes because there's already a test testing implicit coercion, so the uses of the IntEnum
in this new case might as well all be casts - I suggested adding different types to cast to as well to ensure that casting to different widths also works.
numba/tests/test_enums.py
Outdated
@@ -50,6 +50,13 @@ def int_coerce_usecase(x): | |||
else: | |||
return x + Shape.circle | |||
|
|||
def int_cast_usecase(x): | |||
# Implicit coercion of intenums to ints |
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.
# Implicit coercion of intenums to ints | |
# Explicit casting of intenums to ints |
numba/tests/test_enums.py
Outdated
if x > RequestError.internal_error: | ||
return x - RequestError.not_found | ||
else: | ||
return x + int32 (Shape.circle) |
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.
return x + int32 (Shape.circle) | |
return x + int8(Shape.circle) |
numba/tests/test_enums.py
Outdated
if x > RequestError.internal_error: | ||
return x - RequestError.not_found |
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.
if x > RequestError.internal_error: | |
return x - RequestError.not_found | |
if x > int16(RequestError.internal_error): | |
return x - int32(RequestError.not_found) |
numba/tests/test_enums.py
Outdated
@@ -5,7 +5,7 @@ | |||
|
|||
import numpy as np | |||
import unittest | |||
from numba import jit, vectorize | |||
from numba import jit, vectorize, int32 |
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.
from numba import jit, vectorize, int32 | |
from numba import jit, vectorize, int8, int16, int32 |
gpuci run 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.
Thanks for the update - looks good to me!
This PR fixes a enum to int cast problem documented in this issue: #7573 and introduced here: f2311d2.
Fixes #7573