getmatrix() rejects a list of lists; revisit the base.X matrix/vector converters
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 35/100
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- Python
- Étoiles
- 651
- Forks
- 109
- Merge moyen
- 10 j 20 h
- PR mergées (30 j)
- 21
Préparer son environnement
Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de rai-opensource/spatialmath-python
-
Very long delay (10–20 s) on first plot in a fresh environment: Matplotlib font-cache buildPeut-être pris @Doribelove l’a pris il y a 4 jours. Ouvertedocumentation
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
rai-opensource/spatialmath-python#235 ·
Les mainteneurs répondent en général sous 1 jour
-
enhancement
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
rai-opensource/spatialmath-python#32 · 4 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
enhancement
Difficulté 4/5 3-5 jours Accessibilité débutants 45/100
rai-opensource/spatialmath-python#268 ·
Les mainteneurs répondent en général sous 1 jour
-
expand_dims(None) raises TypeError although None is its documented defaultPeut-être pris @Doribelove l’a pris il y a 5 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 52/100
rai-opensource/spatialmath-python#261 ·
Les mainteneurs répondent en général sous 1 jour
-
documentation enhancement
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 15/100
rai-opensource/spatialmath-python#257 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de rai-opensource/spatialmath-python
Issues similaires
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 82/100
btclib-org/btclib-node#2083 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
Gathin23/cleanyourtv#2089 ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
jxxghp/MoviePilot#7212 ·
Les mainteneurs répondent en général sous 1 jour
-
Web transport: small test gapsOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 1 jour
-
cli dx rust
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
NekomyaDev/nudge#278 ·
Les mainteneurs répondent en général sous 1 jour