getmatrix() rejects a list of lists; revisit the base.X matrix/vector converters
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 35/100
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- Python
- Estrelas
- 648
- Forks
- 108
- Merge médio
- 9d 19h
- PRs com merge (30d)
- 9
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de rai-opensource/spatialmath-python
-
Very long delay (10–20 s) on first plot in a fresh environment: Matplotlib font-cache buildTalvez já em andamento @Doribelove assumiu há 4 dias. Abertadocumentation
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
rai-opensource/spatialmath-python#235 ·
Mantenedores costumam responder em até 1 dia
-
enhancement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
rai-opensource/spatialmath-python#32 · 4 comentários ·
Mantenedores costumam responder em até 1 dia
-
enhancement
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 45/100
rai-opensource/spatialmath-python#268 ·
Mantenedores costumam responder em até 1 dia
-
expand_dims(None) raises TypeError although None is its documented defaultTalvez já em andamento @Doribelove assumiu há 5 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 52/100
rai-opensource/spatialmath-python#261 ·
Mantenedores costumam responder em até 1 dia
-
documentation enhancement
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 15/100
rai-opensource/spatialmath-python#257 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
Todas as issues de rai-opensource/spatialmath-python
Issues semelhantes
-
[Resource] agent-claimcheckAberta
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 85/100
yzhao062/awesome-auditable-ai#45 ·
Mantenedores costumam responder em até 3 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
NVIDIA/flare-local-inference#90 ·
Mantenedores costumam responder em até 1 dia
-
area/streaming comp/gateway P2 platform/telegram type/bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
NousResearch/hermes-agent#144897 ·
Mantenedores costumam responder em até 1 dia
-
request-theme
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 66/100
LizardByte/ThemerrDB#9575 ·
Mantenedores costumam responder em até 1 dia