Closed
Description
Describe the issue:
It seems that logical_or
is annotated to return "ndarray[tuple[int, ...], dtype[Any]]"
, but it returns a single bool when called with scalar arguments. Probably other logical_xxx
functions show the same behavior.
I could try to fix it (Returning a union of bool and the current annotation), but need someone pointing me at the location of the annotation.
Reproduce the code example:
import numpy as np
components_proper = np.random.random([3,3]) - .5
components_improper = np.random.random([3,3]) - .5
if np.random.randint(1,3) > 1:
in_SST_ = np.logical_or(np.all(components_proper >= 0.0,axis=-1),
np.all(components_improper >= 0.0,axis=-1))
else:
in_SST_ = np.all(components_proper >= 0.0,axis=-1)
Error message:
error: Incompatible types in assignment (expression has type "numpy.bool[builtins.bool] | ndarray[tuple[int, ...], dtype[numpy.bool[builtins.bool]]]", variable has type "ndarray[tuple[int, ...], dtype[Any]]") [assignment]
Found 1 error in 1 file (checked 1 source file)
Python and NumPy Versions:
NumPy 2.2.1
Python 3.13.1
Type-checker version and settings:
MyPy: 1.14.0
Additional typing packages.
n/a