Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork10.9k
Description
Proposed new feature or change:
I understand that row_stack is being deprecated in numpy 2.0 because it is directly an alias for vstack, but sometimes the spelling row_stack is much more consistent when used next to column_stack.
For example I have the following snippet, which computes, for a binary mask, for each pixel, the number of neighboring pixels that are set:
neighbor_count= (np.row_stack([mask[1:, :],np.zeros(mask.shape[1])])+np.row_stack([np.zeros(mask.shape[1]),mask[:-1, :]])+np.column_stack([mask[:,1:],np.zeros(mask.shape[0])])+np.column_stack([np.zeros(mask.shape[0]),mask[:, :-1]]))
Obviously there are other ways to compute this, e.g. by padding first, or with a scipy 2D convolution, or using vstack and hstack and explicitly passing (1, N) column arrays to hstack, but at least in the way it's written above, it would seem less readable to use vstack for the first two terms and column_stack for the last two.
I would therefore like to suggest reverting this deprecation, even if this function is perhaps marked as discouraged or explicitly points to vstack as an alternative. (As an aside, this deprecation does not seem to be caught by ruff's NPY201 rule).