Last active
September 30, 2025 10:46
-
-
Save flying-sheep/a6464042736b3bffa246b892ce03d883 to your computer and use it in GitHub Desktop.
reproduce numba range bug. run using `hatch test -a`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # usage: `hatch test -a` | |
| [envs.hatch-test] | |
| detached = true | |
| dependencies = ["numba", "numpy<2"] | |
| scripts.run = "python -m {args}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ─────────────────────────────────────────── hatch-test.py3.13 ─────────────────────────────────────────── | |
| Numba version: 0.62.1 | |
| F | |
| ====================================================================== | |
| FAIL: test_range_safe_cast_mixed (__main__.TestRangeNumpy.test_range_safe_cast_mixed) | |
| ---------------------------------------------------------------------- | |
| Traceback (most recent call last): | |
| File "/home/phil/Dev/Python/_reproducers/numba-10215/tests.py", line 21, in test_range_safe_cast_mixed | |
| self.assertPreciseEqual(a - max_i64, numpy.arange(6, 0, -1, dtype=numpy.uint64)) | |
| ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| File "/home/phil/.local/share/hatch/env/virtual/numba-10215/4q5sddP2/hatch-test.py3.13/lib/python3.13/site-packages/numba/tests/support.py", line 459, in assertPreciseEqual | |
| self.fail("when comparing %s and %s: %s" % (first, second, failure_msg)) | |
| ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| AssertionError: when comparing [1] and [6 5 4 3 2 1]: Tuples differ: (1,) != (6,) | |
| First differing element 0: | |
| 1 | |
| 6 | |
| - (1,) | |
| ? ^ | |
| + (6,) | |
| ? ^ | |
| : different shapes | |
| ---------------------------------------------------------------------- | |
| Ran 1 test in 0.313s | |
| FAILED (failures=1) | |
| ─────────────────────────────────────────── hatch-test.py3.12 ─────────────────────────────────────────── | |
| Numba version: 0.62.1 | |
| F | |
| ====================================================================== | |
| FAIL: test_range_safe_cast_mixed (__main__.TestRangeNumpy.test_range_safe_cast_mixed) | |
| ---------------------------------------------------------------------- | |
| Traceback (most recent call last): | |
| File "/home/phil/Dev/Python/_reproducers/numba-10215/tests.py", line 21, in test_range_safe_cast_mixed | |
| self.assertPreciseEqual(a - max_i64, numpy.arange(6, 0, -1, dtype=numpy.uint64)) | |
| File "/home/phil/.local/share/hatch/env/virtual/numba-10215/4q5sddP2/hatch-test.py3.12/lib/python3.12/site-packages/numba/tests/support.py", line 459, in assertPreciseEqual | |
| self.fail("when comparing %s and %s: %s" % (first, second, failure_msg)) | |
| AssertionError: when comparing [1] and [6 5 4 3 2 1]: Tuples differ: (1,) != (6,) | |
| First differing element 0: | |
| 1 | |
| 6 | |
| - (1,) | |
| ? ^ | |
| + (6,) | |
| ? ^ | |
| : different shapes | |
| ---------------------------------------------------------------------- | |
| Ran 1 test in 0.385s | |
| FAILED (failures=1) | |
| ─────────────────────────────────────────── hatch-test.py3.11 ─────────────────────────────────────────── | |
| Numba version: 0.62.1 | |
| F | |
| ====================================================================== | |
| FAIL: test_range_safe_cast_mixed (__main__.TestRangeNumpy.test_range_safe_cast_mixed) | |
| ---------------------------------------------------------------------- | |
| Traceback (most recent call last): | |
| File "/home/phil/Dev/Python/_reproducers/numba-10215/tests.py", line 21, in test_range_safe_cast_mixed | |
| self.assertPreciseEqual(a - max_i64, numpy.arange(6, 0, -1, dtype=numpy.uint64)) | |
| File "/home/phil/.local/share/hatch/env/virtual/numba-10215/4q5sddP2/hatch-test.py3.11/lib/python3.11/site-packages/numba/tests/support.py", line 459, in assertPreciseEqual | |
| self.fail("when comparing %s and %s: %s" % (first, second, failure_msg)) | |
| AssertionError: when comparing [1] and [6 5 4 3 2 1]: Tuples differ: (1,) != (6,) | |
| First differing element 0: | |
| 1 | |
| 6 | |
| - (1,) | |
| ? ^ | |
| + (6,) | |
| ? ^ | |
| : different shapes | |
| ---------------------------------------------------------------------- | |
| Ran 1 test in 0.334s | |
| FAILED (failures=1) | |
| ─────────────────────────────────────────── hatch-test.py3.10 ─────────────────────────────────────────── | |
| Numba version: 0.62.1 | |
| F | |
| ====================================================================== | |
| FAIL: test_range_safe_cast_mixed (__main__.TestRangeNumpy) | |
| ---------------------------------------------------------------------- | |
| Traceback (most recent call last): | |
| File "/home/phil/Dev/Python/_reproducers/numba-10215/tests.py", line 21, in test_range_safe_cast_mixed | |
| self.assertPreciseEqual(a - max_i64, numpy.arange(6, 0, -1, dtype=numpy.uint64)) | |
| File "/home/phil/.local/share/hatch/env/virtual/numba-10215/4q5sddP2/hatch-test.py3.10/lib/python3.10/site-packages/numba/tests/support.py", line 459, in assertPreciseEqual | |
| self.fail("when comparing %s and %s: %s" % (first, second, failure_msg)) | |
| AssertionError: when comparing [1] and [6 5 4 3 2 1]: Tuples differ: (1,) != (6,) | |
| First differing element 0: | |
| 1 | |
| 6 | |
| - (1,) | |
| ? ^ | |
| + (6,) | |
| ? ^ | |
| : different shapes | |
| ---------------------------------------------------------------------- | |
| Ran 1 test in 0.378s | |
| FAILED (failures=1) | |
| ─────────────────────────────────────────── hatch-test.py3.9 ──────────────────────────────────────────── | |
| Numba version: 0.60.0 | |
| F | |
| ====================================================================== | |
| FAIL: test_range_safe_cast_mixed (__main__.TestRangeNumpy) | |
| ---------------------------------------------------------------------- | |
| Traceback (most recent call last): | |
| File "/home/phil/Dev/Python/_reproducers/numba-10215/tests.py", line 21, in test_range_safe_cast_mixed | |
| self.assertPreciseEqual(a - max_i64, numpy.arange(6, 0, -1, dtype=numpy.uint64)) | |
| File "/home/phil/.local/share/hatch/env/virtual/numba-10215/4q5sddP2/hatch-test.py3.9/lib/python3.9/site-packages/numba/tests/support.py", line 428, in assertPreciseEqual | |
| self.fail("when comparing %s and %s: %s" % (first, second, failure_msg)) | |
| AssertionError: when comparing [1] and [6 5 4 3 2 1]: Tuples differ: (1,) != (6,) | |
| First differing element 0: | |
| 1 | |
| 6 | |
| - (1,) | |
| ? ^ | |
| + (6,) | |
| ? ^ | |
| : different shapes | |
| ---------------------------------------------------------------------- | |
| Ran 1 test in 0.362s | |
| FAILED (failures=1) | |
| ─────────────────────────────────────────── hatch-test.py3.8 ──────────────────────────────────────────── | |
| Numba version: 0.58.1 | |
| F | |
| ====================================================================== | |
| FAIL: test_range_safe_cast_mixed (__main__.TestRangeNumpy) | |
| ---------------------------------------------------------------------- | |
| Traceback (most recent call last): | |
| File "/home/phil/Dev/Python/_reproducers/numba-10215/tests.py", line 21, in test_range_safe_cast_mixed | |
| self.assertPreciseEqual(a - max_i64, numpy.arange(6, 0, -1, dtype=numpy.uint64)) | |
| File "/home/phil/.local/share/hatch/env/virtual/numba-10215/4q5sddP2/hatch-test.py3.8/lib/python3.8/site-packages/numba/tests/support.py", line 434, in assertPreciseEqual | |
| self.fail("when comparing %s and %s: %s" % (first, second, failure_msg)) | |
| AssertionError: when comparing [1] and [6 5 4 3 2 1]: Tuples differ: (1,) != (6,) | |
| First differing element 0: | |
| 1 | |
| 6 | |
| - (1,) | |
| ? ^ | |
| + (6,) | |
| ? ^ | |
| : different shapes | |
| ---------------------------------------------------------------------- | |
| Ran 1 test in 0.376s | |
| FAILED (failures=1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import unittest | |
| import numba | |
| import numpy | |
| from numba.tests.support import TestCase | |
| class TestRangeNumpy(TestCase): | |
| def test_range_safe_cast_mixed(self): | |
| @numba.njit | |
| def my_arange(start, stop, step): | |
| x = numpy.zeros(len(range(start, stop, step)), dtype=numpy.uint64) | |
| i = 0 | |
| for v in range(start, stop, step): | |
| x[i] = v | |
| i += 1 | |
| return x | |
| max_i64 = numpy.uint64(numpy.iinfo(numpy.int64).max) | |
| a = my_arange(max_i64+6, max_i64, numpy.int64(-1)) | |
| self.assertPreciseEqual(a - max_i64, numpy.arange(6, 0, -1, dtype=numpy.uint64)) | |
| if __name__ == '__main__': | |
| print("Numba version:", numba.__version__) | |
| unittest.main(exit=False, testRunner=unittest.runner.TextTestRunner(sys.stdout)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment