Describe the issue:
Slice-assigning values into a StringDType array silently corrupts the target elements whenever the source slice contains at least one ASCII string of exactly 255 characters.
-
The assignment raises no exception, but a subsequent equality check fails (AssertionError).
-
Repeating the same assignment twice makes the data compare equal, suggesting the first write leaves the internal storage in an inconsistent state.
Reproduce the code example:
import numpy as np
chunk_name = np.array(
[
'0' * 256,
'0' * 256,
'0' * 256,
'0' * 255,
'0' * 256,
'0' * 255,
'0' * 256,
'0' * 256,
'0' * 255,
],
dtype=np.dtypes.StringDType()
)
events_name = np.array(
[
'0' * 255,
'0' * 256,
'0' * 256,
'0' * 255,
'0' * 256,
'0' * 255,
'',
'',
'',
'',
''
],
dtype=np.dtypes.StringDType()
)
N = 9
events_name[1:N+1] = chunk_name
assert np.all(np.strings.equal(events_name[1:N+1], chunk_name))
Error message:
Traceback (most recent call last):
File "/shared/home/Fortitude42/work/x.py", line 39, in <module>
assert np.all(np.strings.equal(events_name[1:N+1], chunk_name))
Python and NumPy Versions:
- Python version: 3.11.12
- NumPy version: 2.2.5
Runtime Environment:
No response
Context for the issue:
No response
Describe the issue:
Slice-assigning values into a StringDType array silently corrupts the target elements whenever the source slice contains at least one ASCII string of exactly 255 characters.
The assignment raises no exception, but a subsequent equality check fails (AssertionError).
Repeating the same assignment twice makes the data compare equal, suggesting the first write leaves the internal storage in an inconsistent state.
Reproduce the code example:
Error message:
Python and NumPy Versions:
Runtime Environment:
No response
Context for the issue:
No response