我写的 numpy 类型提示没有按我的预期工作。
我有一个
ndarray
[
[ 894.45481226 279.40789779 989.63422511 296.75358057]
[1546.42116975 57.95559617 754.60849398 482.2156838 ]
[1615.88569942 497.95665529 1642.07014504 253.87915567]
[ 218.7096641 1212.50328182 1117.34125593 904.91145497]
]
我尝试写出像
numpy.typing.NDArray[numpy.typing.NDArray[numpy.float64]]
这样的提示,但皮兰斯告诉我
Could not specialize type "NDArray[ScalarType@NDArray]"
Type "NDArray[float64]" cannot be assigned to type "generic"
"NDArray[float64]" is incompatible with "generic"
我不确定是否有办法使其正确。
这是一个形状为 [4, 4] 的
numpy.typing.NDArray[numpy.float64]
。它的形状描述了嵌套。我不相信您可以在没有第三方工具的情况下对类型中的形状进行编码