Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
added unit test to reproduce issue #8370
  • Loading branch information
bszollosinagy committed Aug 21, 2022
commit 72bbc5e8a2fbe2d1236784aebb2c8738821c25ba
19 changes: 19 additions & 0 deletions numba/tests/test_array_manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,25 @@ def test_broadcast_arrays_incompatible_shapes_raise_valueerror(self):
self.assertIn("shape mismatch: objects cannot be broadcast to a single shape",
str(raises.exception))

def test_readonly_after_flatten(self):
# Reproduces Issue #8370
def unfold_flatten(x, y):
r, c = x.shape
a = np.broadcast_to(x, (y, r, c))
b = np.swapaxes(a, 0, 1)
cc = b.flatten()
d = np.reshape(cc, (-1, c))
d[y - 1:, :] = d[: 1 - y]
return d

pyfunc = unfold_flatten
cfunc = jit(nopython=True)(pyfunc)

# If issue #8370 is not fixed: This will fail with "NumbaTypeError:
# Cannot modify readonly array of type: readonly array(int32, 2d, C)"
Comment thread
bszollosinagy marked this conversation as resolved.
Resolved
cfunc(np.array([[1, 1, 1], [2, 2, 2], [3, 3, 3]]), 2)




if __name__ == '__main__':
Expand Down