You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
searchsorted needs to broadcast batch shapes #1014
importnumpyasnpfromscipy._externalimportarray_api_extraasxpxrng=np.random.default_rng(2398198374572881)
shape_1d= (5,)
shape_2d= (2, 5)
x=np.sort(rng.random(shape_1d), axis=-1)
y=rng.random(shape_2d)
xpx.searchsorted(x, y) # OKx=np.sort(rng.random(shape_2d), axis=-1)
y=rng.random(shape_1d)
xpx.searchsorted(x, y) # not OK# ValueError: input operand has more dimensions than allowed by the axis remapping
My workaround there was to broadcast the batch shapes (e.g. batch_shape = xp.broadcast_shapes(x1.shape[:-1], x2.shape[:-1])) and reshape the arguments accordingly.
Activity
lucascolley commentedon Oct 7, 2026
PR welcome