[Python] NumbaPerformanceWarning about contiguous arrays, although both arrays are already...

Discussão em 'Python' iniciado por Stack, Fevereiro 8, 2025.

  1. Stack

    Stack Membro Participativo

    I am having a problem with removing this warning, before publishing a package on PyPI.

    As a summary, this is the function that I am using to speed up the np.dot() function:

    @nb.jit(nb.float64[:,:](nb.float64[:,:], nb.float64[:,:]), nopython=True)
    def fastDot(X, Y):
    return np.dot(X, Y)


    And the aim is to use this matrix to multiply a matrix of lagged signals with the eigenvectors, it can be also any other matrix:

    # Compute principal components
    PC = fastDot(X, eigenVectors)


    This is where I get the following warning:

    NumbaPerformanceWarning: np.dot() is faster on contiguous arrays, called on (Array(float64, 2, 'A', False, aligned=True), Array(float64, 2, 'A', False, aligned=True))
    return np.dot(X, Y)


    I have also used this line just before the fastDot() call:

    eigenVectors, X = np.ascontiguousarray(eigenVectors), np.ascontiguousarray(X)


    Still no success.

    I know it's not a huge problem, but I would like to remove this warning without using statically typed warnings.

    Can someone please help me in:

    1. Understanding why this is happening
    2. How can I remove this?

    Thank you so much in advance!

    Continue reading...

Compartilhe esta Página