The numpy type hints I wrote don’t work as I expected.
I have a ndarray
<code> [
[ 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]
]
</code>
<code> [
[ 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]
]
</code>
[
[ 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]
]
And I tried to write hint like numpy.typing.NDArray[numpy.typing.NDArray[numpy.float64]]
,but Pylance tell me
<code>Could not specialize type "NDArray[ScalarType@NDArray]"
Type "NDArray[float64]" cannot be assigned to type "generic"
"NDArray[float64]" is incompatible with "generic"
</code>
<code>Could not specialize type "NDArray[ScalarType@NDArray]"
Type "NDArray[float64]" cannot be assigned to type "generic"
"NDArray[float64]" is incompatible with "generic"
</code>
Could not specialize type "NDArray[ScalarType@NDArray]"
Type "NDArray[float64]" cannot be assigned to type "generic"
"NDArray[float64]" is incompatible with "generic"
I’m not sure if there is a way to make it correct.