implementing np.roll affecting non-contiguous arrays in NumPy 1.24.0
I'm working on a personal project and I'm working on a project and hit a roadblock. I'm experiencing unexpected behavior when using `np.roll` on a non-contiguous array in NumPy 1.24.0. I have a 2D array that I'm reshaping and then trying to roll its columns. However, after rolling, the output doesn't seem to reflect the expected shifted values. Here's the code snippet where the scenario occurs: ```python import numpy as np # Create a contiguous 2D array array = np.arange(12).reshape(3, 4) # Create a non-contiguous view of the array by taking every second row non_contiguous_array = array[::2, :] print("Original non-contiguous array:\n", non_contiguous_array) # Attempting to roll the non-contiguous array rolled_array = np.roll(non_contiguous_array, shift=1, axis=1) print("Rolled non-contiguous array:\n", rolled_array) ``` When I run this, I expect the last column to wrap around to the first column, but the output is not as anticipated. Instead of rolling the data properly, I see that the rows appear unchanged. The output is: ``` Original non-contiguous array: [[0 1 2 3] [8 9 10 11]] Rolled non-contiguous array: [[3 0 1 2] [11 8 9 10]] ``` It seems like `np.roll` may not be handling the non-contiguous memory layout correctly. I have also tried using `np.ascontiguousarray(non_contiguous_array)` before rolling it, but that doesn't seem to resolve the scenario either. Am I missing something here, or is there a known limitation with `np.roll` on non-contiguous arrays? Any insights would be appreciated. I'm working on a service that needs to handle this. What am I doing wrong? I'm working on a application that needs to handle this. Any ideas what could be causing this?