ValueError when using np.concatenate with differing shapes in NumPy 1.24.0
I'm refactoring my project and I've encountered a strange issue with I'm working with NumPy 1.24.0 and trying to concatenate two arrays of different shapes along a new axis. I expect it to work without issues, but I encounter a `ValueError`. Here’s what I’ve done so far: I have two arrays: ```python import numpy as np a = np.array([[1, 2], [3, 4]]) # shape (2, 2) b = np.array([[5, 6]]) # shape (1, 2) ``` I want to concatenate these arrays along axis 0, but since they have different leading dimensions, I thought I could expand the dimensions of the smaller array first: ```python b_expanded = np.expand_dims(b, axis=0) # shape (1, 1, 2) result = np.concatenate((a[:, np.newaxis, :], b_expanded), axis=0) ``` However, when I run this, I get the following behavior: ``` ValueError: all the input array dimensions for the concatenation axis must match exactly. ``` The shapes seem compatible after the expansion, so I’m not sure what’s going wrong. I've double-checked the shapes and confirmed that `a[:, np.newaxis, :]` results in a shape of (2, 1, 2), but it seems there’s a mismatch when I try to concatenate with `b_expanded`. What am I missing here? Is there a better way to achieve this concatenation? Any help would be appreciated! This issue appeared after updating to Python stable. Any examples would be super helpful. What am I doing wrong? I'd love to hear your thoughts on this.