Inconsistent declaration of `ndarray.__array_ufunc__`

46 views Asked by At

While writing an ndarray subclass, Mypy flags a problem related to the declaration of the method argument in __array_ufunc__.

The __array_ufunc__ docs say:

  • method is a string indicating how the Ufunc was called, either "__call__" to indicate it was called directly, or one of its methods: "reduce", "accumulate", "reduceat", "outer", or "at".

Which is consistent with the ufunc methods documentation.

However, Numpy declares __array_ufunc__ as:

def __array_ufunc__(
    self,
    ufunc: ufunc,
    method: L["__call__", "reduce", "reduceat", "accumulate", "outer", "inner"],
    *inputs: Any,
    **kwargs: Any,
) -> Any: ...

Method "at" is missing, replaced by a mysterious "inner", which is not an ufunc method.

Is this a bug? Am I missing something?

0

There are 0 answers