PyCharm 3.1.1 and Numpy community, "matrix" cannot be called ", but code works

I have the following code:

import numpy as np if __name__ == "__main__": m = np.matrix([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) print(m) 

The code works as expected, but PyCharm seems to think that the "matrix" is not callable. See screenshot.

enter image description here

Since the code works, explicitly a โ€œmatrixโ€ can be called. So what is PyCharm complaining about? Am I wrong here, or is it PyCharm? How to suppress this error?

+2
source share
1 answer

A simple workaround, at least until the error is fixed, is to use np.mat(...) instead of np.matrix(...) .

However, note that np.mat will avoid making copies if the input is already a matrix, and therefore you cannot use it to do something like make defensive copies.

+1
source

Source: https://habr.com/ru/post/1204772/


All Articles