getmatrix() rejects a list of lists; revisit the base.X matrix/vector converters
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 35/100
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- Python
- Sterne
- 648
- Forks
- 108
- Ø Merge
- 10 T. 20 Std.
- Gemergte PRs (30 T.)
- 21
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus rai-opensource/spatialmath-python
-
Very long delay (10–20 s) on first plot in a fresh environment: Matplotlib font-cache buildEvtl. vergeben @Doribelove hat das vor 4 Tagen übernommen. Offendocumentation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
rai-opensource/spatialmath-python#235 ·
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
rai-opensource/spatialmath-python#32 · 4 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
rai-opensource/spatialmath-python#268 ·
Maintainer antworten meist innerhalb von 1 Tag
-
expand_dims(None) raises TypeError although None is its documented defaultEvtl. vergeben @Doribelove hat das vor 5 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 52/100
rai-opensource/spatialmath-python#261 ·
Maintainer antworten meist innerhalb von 1 Tag
-
documentation enhancement
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 15/100
rai-opensource/spatialmath-python#257 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in rai-opensource/spatialmath-python
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
sylvainmetayer/homelab#851 ·
Maintainer antworten meist innerhalb von 1 Tag
-
needs triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
Add `ty-pre-commit` hookOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
kubeflow/docs-agent#279 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 67/100
Qiskit/qiskit-ibm-runtime#3523 ·
Maintainer antworten meist innerhalb von 1 Tag