Repository navigation
Support numba 0.68 #45
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
| from numbox.core.bindings.errno import errno_get | ||
| from numbox.core.bindings.libc import getenv, memcpy | ||
| from numbox.core.bindings.call import _call_lib_func | ||
| from numbox.core.configurations import numba_version | ||
| from numbox.core.proxy.proxy import proxy, proxy_if_available, make_proxy_name | ||
| from numbox.utils.derive_wap import DeriveFunctionType, DeriveWAP, jit_addr_supported | ||
| from numbox.utils.lowlevel import array_data_p, get_unicode_data_p | ||
|
|
@@ -602,10 +603,11 @@ def call_through_declared_plain(f, x): | |
|
|
||
|
|
||
| @pytest.mark.skipif(not jit_addr_supported(), reason=_JIT_ADDR_REASON) | ||
| def test_proxy_as_func_mixed_with_a_numba_native_wrapper_fails_to_unify(): | ||
| """Characterization of a narrowing: a heterogeneous tuple of function values is refused. | ||
| def test_proxy_as_func_mixed_with_a_numba_native_wrapper_fails_to_unify_for_numba_lt_68_and_works_for_numba_gte_68(): | ||
| """Characterization of a narrowing: a heterogeneous tuple of function values is refused | ||
| for numba<0.68. | ||
|
|
||
| numba unifies a tuple's element types in ``unified_function_type`` with a bare | ||
| numba<0.68.0 unifies a tuple's element types in ``unified_function_type`` with a bare | ||
| class-identity comparison, which runs before any of numbox's conversions get a say, so a | ||
| ``DeriveFunctionType`` element beside a plain ``FunctionType`` one trips a message-less | ||
| ``AssertionError`` out of ``numba/core/utils.py``. The same tuple returned a value while | ||
|
|
@@ -615,7 +617,7 @@ def test_proxy_as_func_mixed_with_a_numba_native_wrapper_fails_to_unify(): | |
| Why the two types cannot simply be made to compare equal is worked through in | ||
| ``test/utils/test_derive_wap.py::test_the_derive_type_stays_distinct_from_the_plain_function_type``. | ||
|
|
||
| numba's assert carries no message, so the frame it was raised from is checked instead of any | ||
| numba<0.68.0's assert carries no message, so the frame it was raised from is checked instead of any | ||
| text. Matching on ``AssertionError`` alone would be satisfied by an unrelated one raised | ||
| anywhere in the same call. | ||
| """ | ||
|
|
@@ -629,11 +631,14 @@ def native(x): | |
| def use_pair(pair, x): | ||
| return pair[0](x) + pair[1](x) | ||
|
|
||
| with pytest.raises(AssertionError) as raised: | ||
| use_pair((aux_raises.as_func, foreign), -3.0) | ||
| assert raised.traceback[-1].name == "unified_function_type", ( | ||
| f"the refusal moved out of numba's function-type unification: {raised.traceback[-1].name}" | ||
| ) | ||
| if numba_version >= 68: | ||
| assert use_pair((aux_raises.as_func, foreign), -3.0) == 5 | ||
|
Comment on lines
+634
to
+635
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From the fake Slim Shady: test/core/test_proxy.py:633-634 docs/numbox.core.proxy.rst and docs/numbox.core.work.rst still say this fails from 0.61 onward.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From the fake Slim Shady: Still there at 843a85f. In work.rst one sentence marks the .as_func tuple fixed in 0.68.0. The next sentence at 600-603 says the tuple 'fails on the same assertion' and names no version. The test_proxy summary line at 607 still says 'refused', but the body returns 5 on 0.68.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From the fake Slim Shady: One more sentence in the same work.rst passage. Lines 604-607 say two plain CompileResultWAP values with different signatures 'fail identically'. Like the .as_func tuple, they unify on 0.68.0: from numba import njit, float64, int64
from numbox.utils.highlevel import CompileResultWAP
@njit(float64(float64))
def f(x):
return x + 10.0
@njit(int64(float64))
def g(x):
return int(x * 2)
a = CompileResultWAP(f.get_compile_result(f.nopython_signatures[0]))
b = CompileResultWAP(g.get_compile_result(g.nopython_signatures[0]))
@njit
def use_pair(pair, x):
return pair[0](x) + pair[1](x)
try:
print("result", use_pair((a, b), 3.0))
except AssertionError as e:
import traceback
print("AssertionError from", traceback.extract_tb(e.__traceback__)[-1].name)This prints 'result 19.0' on 0.68.0 and 'AssertionError from unified_function_type' on 0.67.0. |
||
| else: | ||
| with pytest.raises(AssertionError) as raised: | ||
| use_pair((aux_raises.as_func, foreign), -3.0) | ||
| assert raised.traceback[-1].name == "unified_function_type", ( | ||
| f"the refusal moved out of numba's function-type unification: {raised.traceback[-1].name}" | ||
| ) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
|
|
||
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 the fake Slim Shady:
pyproject.toml:12
On Windows this lets in the cell that fails in CI. numba 0.68 builds the archive member name with str(Path(...)), so there it carries backslashes and no member matches, source archives included. That one is numba's, reported as numba/numba#10889 with a fix in numba/numba#10896, but the fix only changes the separator, and a .pyc-only archive still has no .py member to hash.