SBU-BMI / wsinfer

🔥 🚀 Blazingly fast pipeline for patch-based classification in whole slide images
https://wsinfer.readthedocs.io
Apache License 2.0
55 stars 9 forks source link

types for opencv causing errors #210

Closed kaczmarj closed 6 months ago

kaczmarj commented 6 months ago

cv2 has a typ Mat, which is aliased to a generic numpy array. previously, we expected uint8 arrays, not generics. this causes issues when type checking

wsinfer/patchlib/patch.py:56: error: Incompatible types in assignment (expression has type "Mat | ndarray[Any, dtype[generic]]", variable has type "ndarray[Any, dtype[signedinteger[Any]]]")  [assignment]
wsinfer/patchlib/patch.py:68: error: Unsupported operand types for * ("ndarray[Any, dtype[generic]]" and "ndarray[Any, dtype[floating[Any]]]")  [operator]
wsinfer/patchlib/patch.py:118: error: Incompatible return value type (got "tuple[Any, Sequence[ndarray[Any, dtype[generic]]], ndarray[Any, dtype[signedinteger[Any]]]]", expected "tuple[Any, Sequence[ndarray[Any, dtype[signedinteger[Any]]]], ndarray[Any, dtype[signedinteger[Any]]]]")  [return-value]
wsinfer/patchlib/segment.py:50: error: Incompatible types in assignment (expression has type "ndarray[Any, dtype[generic]]", variable has type "ndarray[Any, dtype[unsignedinteger[_8Bit]]]")  [assignment]
wsinfer/patchlib/segment.py:63: error: Incompatible types in assignment (expression has type "ndarray[Any, dtype[generic]]", variable has type "ndarray[Any, dtype[unsignedinteger[_8Bit]]]")  [assignment]
wsinfer/patchlib/segment.py:66: error: Incompatible types in assignment (expression has type "Mat | ndarray[Any, dtype[generic]]", variable has type "ndarray[Any, dtype[unsignedinteger[_8Bit]]]")  [assignment]

found in #209