getmatrix() rejects a list of lists; revisit the base.X matrix/vector converters
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- Python
- 星标
- 648
- 派生
- 108
- 平均合并
- 10 天 20 小时
- 30 天内合并 PR
- 21
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
rai-opensource/spatialmath-python 的其他 Issue
-
Very long delay (10–20 s) on first plot in a fresh environment: Matplotlib font-cache build可能已有人在做 @Doribelove 于 4 天前认领。 未关闭documentation
难度 2/5 1-3 小时 新手友好度 74/100
rai-opensource/spatialmath-python#235 ·
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 65/100
rai-opensource/spatialmath-python#32 · 4 条评论 ·
维护者通常 1 天内回复
-
enhancement
难度 4/5 3-5 天 新手友好度 45/100
rai-opensource/spatialmath-python#268 ·
维护者通常 1 天内回复
-
expand_dims(None) raises TypeError although None is its documented default可能已有人在做 @Doribelove 于 5 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 52/100
rai-opensource/spatialmath-python#261 ·
维护者通常 1 天内回复
-
documentation enhancement
难度 5/5 一周以上 新手友好度 15/100
rai-opensource/spatialmath-python#257 · 1 条评论 ·
维护者通常 1 天内回复
查看 rai-opensource/spatialmath-python 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 85/100
521xueweihan/HelloGitHub#4115 ·
-
get_lldp_neighbors_detail: query asks for 'max-address' (typo for 'mac-address'), so remote_chassis_id is always empty可能已有人在做 @Jah-yee 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 88/100
-
lesson-submission pending-review
难度 1/5 1 小时以内 新手友好度 74/100
Ikalus1988/MisakaNet#3899 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
aws-samples/sample-per-model-bedrock#549 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 90/100