Given an (2,2,3,3,3)
array of 3D-cartesian coordinates along the last dimension, what is the syntax for computing the Euclidean between pairwise values in XA and XB using scipy.spatial.distance.cdist
to yield an output array with shape (2, 3, 3)
?
XA = np.random.normal(size=(2,2,3,3,3))
XB = np.random.normal(size=(2,2,3,3,3))
dist = cdist(XA[:, 0, ...], XB[:, 1, ...], 'seuclidean')
Returns ValueError: XA must be a 2-dimensional array
. As such, alternative to loops what is the pythonic syntax for computing cdist(XA[:, 0], XB[:, 1])
?