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
BUG: Infinite Loop in numpy.base_repr #26143
Comments
There seems to be an issue with the implementation of the abs function for int8, int16 ... int64. All corresponding negative edge values raise an overflow error when the absolute value is taken. I'm not at all familiar with the Numpy codebase, so I couldn't find where the abs function for these is implemented. |
Thanks for reporting! This still is an issue on current main... Lines 2139 to 2154 in e1bf1d6
I think the fix is simple: write p.s. I don't quite like that |
Describe the issue:
A call to
numpy.base_repr
with a minimal value of the underlying int-type results in an infinite loop, e.g. -128 fornp.int8
. The problem seems to be a call toabs
.Reproduce the code example:
Error message:
RuntimeWarning: overflow encountered in scalar absolute num = abs(number)
Python and NumPy Versions:
Python 3.12.1
numpy 1.26.4
Runtime Environment:
[{'numpy_version': '1.26.4',
'python': '3.12.1 (tags/v3.12.1:2305ca5, Dec 7 2023, 22:03:25) [MSC v.1937 '
'64 bit (AMD64)]',
'uname': uname_result(system='Windows', node='EVK-NB-649', release='11', version='10.0.22621', machine='AMD64')},
{'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
'found': ['SSSE3',
'SSE41',
'POPCNT',
'SSE42',
'AVX',
'F16C',
'FMA3',
'AVX2'],
'not_found': ['AVX512F',
'AVX512CD',
'AVX512_SKX',
'AVX512_CLX',
'AVX512_CNL',
'AVX512_ICL']}},
{'architecture': 'Haswell',
'filepath': 'C:\Users\$username\AppData\Local\Programs\Python\Python312\Lib\site-packages\numpy.libs\libopenblas64__v0.3.23-293-gc2f4bdbb-gcc_10_3_0-2bde3a66a51006b2b53eb373ff767a3f.dll',
'internal_api': 'openblas',
'num_threads': 16,
'prefix': 'libopenblas',
'threading_layer': 'pthreads',
'user_api': 'blas',
'version': '0.3.23.dev'}]
None
Context for the issue:
The current implementation of
numpy.base_repr
is not safely usable.The text was updated successfully, but these errors were encountered: