Home > Software design >  Deprected numpy.matlib
Deprected numpy.matlib

Time:01-05

I'm trying to import numpy.matlib but I receive this warning:

Importing from numpy.matlib is deprecated since 1.19.0. The matrix subclass is not the recommended way to represent matrices or deal with linear algebra.

I'm using it for:

np.matlib.repmat(I, 1400, 1)

How can I solve it? Doing the repmat without using the .matlib class?

CodePudding user response:

The warning message you are seeing indicates that the numpy.matlib module is now deprecated and you should not use it in your code. Instead, you should use the numpy module to perform matrix operations.

For example, you can use the 'numpy.array' function to create a matrix, and use the various functions in the numpy module to perform operations on it.

Example: import numpy as np

Create a 3x3 matrix

A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])

Multiply A by 2

B = A * 2

Take the transpose of B

C = B.T

You can also check official documentation. Thanks , hope it helps

  • Related