-1

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?

TFAE
  • 117
  • 4
  • From the documentation: *It is no longer recommended to use this class, even for linear algebra. Instead use regular arrays. The class may be removed in the future.*, see https://numpy.org/doc/stable/reference/generated/numpy.matrix.html#numpy.matrix – Carlos Horn Jan 04 '23 at 12:41
  • One of many SO seeking alternatives to `repmat`: https://stackoverflow.com/questions/32238227/numpy-tile-did-not-work-as-matlab-repmat. Generally `np.tile` can used instead, though you may have to wrap your brain around the differences in 'order'.. The code for `matlib.repmat` uses a mix or `reshape` and `repeat` https://github.com/numpy/numpy/blob/v1.24.0/numpy/matlib.py#L330-L378 – hpaulj Jan 04 '23 at 16:54

1 Answers1

1

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

shiva
  • 5,083
  • 5
  • 23
  • 42
Suksham
  • 36
  • 5