getmatrix() rejects a list of lists; revisit the base.X matrix/vector converters
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Start with getmatrix and getvector in the spatialmath base package, plus isvector and ismatrix, and run the three examples in the issue to reproduce the TypeError and the flat-list reshape. Check spatialmath/base/types.py for Points2 and Points3. The issue leaves open whether the flat-list reshape is intended and whether the type aliases should widen, so settle those with a maintainer before changing code. Done means nested lists and tuples are converted and shape-checked, with tests for the existing converters.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
getmatrix() (and getvector()) reject the most natural way to write a set of points: a list of lists. Found while adding type hints to RTB, where a 2xN path of waypoints is passed to a function.
from spatialmath.base import getmatrix
getmatrix([[0, 1, 2], [0, 1, 0]], (2, None)) # TypeError: argument must be scalar or ndarray
getmatrix([[0, 0], [1, 1], [2, 0]], (2, None)) # TypeError
getmatrix(np.zeros((2, 5)), (2, None)) # OK, (2, 5)
Two related problems:
- Nested lists and tuples are rejected. The function accepts a scalar, a 1D array-like or an ndarray, but not a list of rows. I would expect it to convert these with
np.asarrayand then check the shape againstshape, raisingValueErroron mismatch. - A flat list is silently reshaped.
getmatrix([0, 1, 2, 3], (2, None))returns a(2, 2)array. That is convenient for(2,2)but can hide a mistake when the caller meant a path of 2 points or a different layout.
Also, Points2 and Points3 in spatialmath.base.types are plain NDArray, so the type hint says "ndarray only" while the docstrings in callers say "array_like".
Suggested direction:
- Make
getmatrix(and the otherbase.X...converters) accept array-likes of any nesting and validate the shape, so callers can replace hand-writtennp.asarray(...)plusndim/shapechecks with one call. - Decide whether the flat-list reshape is intended, and document it if so.
- Consider whether
Points2/Points3should widen to accept sequences.
I'll revisit the base.getvector/getmatrix/isvector/ismatrix family together, since the same question applies to all of them.
- Lingua principale
- Python
- Stelle
- 651
- Fork
- 109
- Merge medio
- 10g 20h
- PR unite (30g)
- 21
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di rai-opensource/spatialmath-python
-
Very long delay (10–20 s) on first plot in a fresh environment: Matplotlib font-cache buildForse già presa @Doribelove l’ha presa 5 giorni fa. Apertadocumentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
rai-opensource/spatialmath-python#235 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
rai-opensource/spatialmath-python#32 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
rai-opensource/spatialmath-python#268 ·
I maintainer di solito rispondono entro 1 giorno
-
expand_dims(None) raises TypeError although None is its documented defaultForse già presa @Doribelove l’ha presa 6 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 52/100
rai-opensource/spatialmath-python#261 ·
I maintainer di solito rispondono entro 1 giorno
-
documentation enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
rai-opensource/spatialmath-python#257 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di rai-opensource/spatialmath-python
Issue simili
-
lesson-submission pending-review
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
Ikalus1988/MisakaNet#3956 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
aws-samples/sample-per-model-bedrock#574 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 70/100
521xueweihan/HelloGitHub#4133 ·
-
plot_components fails for logistic models with minmax scaling and no floorForse già presa @RaphaelFakhri l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 4 giorni
-
Update migenAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
YosysHQ/oss-cad-suite-build#220 ·