Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

`searchsorted` needs to broadcast batch shapes

Aperta
#1,014 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
56/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Start by locating the searchsorted implementation and its tests; the issue provides a reproducer for the failing case where x has shape (2, 5) and y has shape (5,). Read how the function handles batch dimensions, then run the relevant tests with this case. Done means the batch shapes broadcast and the call succeeds with the expected indices.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Ran into this in scipy/scipy#26324:

import numpy as np
from scipy._external import array_api_extra as xpx

rng = 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)  # OK

x = 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.

Lingua principale
Python
Stelle
33
Fork
33
Merge medio
1h 16m
PR unite (30g)
32

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di data-apis/array-api-extra

Tutte le issue di data-apis/array-api-extra

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.