[Python] NumPy Typing of Array (Vector, Matrix) of Floats

Discussão em 'Python' iniciado por Stack, Outubro 2, 2024.

  1. Stack

    Stack Membro Participativo

    What's the proper way to add type hints to a function with NumPy arrays?
    Specifically hint the types are vectors / matrices of any supported float.

    def MyFun( myVectorFloat: <Typing>, myMatrixFloat: <Typing> ):
    some code...


    So I want to type hint myVectorFloat as a vector (len(myVectorFloat.shape) == 1) and myMatriFloat as a matrix (len(myMatrixFloat.shape) == 2).

    I want support for Float16, Float32 and Float64.

    What's it the proper way to achieve that?

    Continue reading...

Compartilhe esta Página