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 runs as expected, but PyCharm seems to think that 'matrix' is not callable. See screenshot.
Since the code runs, clearly 'matrix' is callable. So what's PyCharm complaining about? Am I in the wrong here or is PyCharm? How do I suppress this error?
A simple workaround, at least until the bug is fixed, is to use
np.mat(...)
instead ofnp.matrix(...)
.However, note that
np.mat
will avoid making copies if the input is already a matrix and so you can't use it to do things like make defensive copies.