-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
pylint-dev/astroid
#664Labels
Bug 🪲Needs astroid Brain 🧠Needs a brain tip in astroid (then an astroid upgrade)Needs a brain tip in astroid (then an astroid upgrade)
Description
Hi there!
Pylint gives a false-positive error while using numpy.zeros_like().
This numpy method will return a ndarray object. But while trying to address this object by indexing, pylint will raise an error although python works fine.
Code to reproduce:.
import numpy as np
a = np.array([[1, 2, 3], [4, 5, 6]])
print(a)
b = np.zeros_like(a)
print(b)
index = (0, 1)
a[index] = 9
print(a)
b[index] = 9
print(b)
Current behavior
Pylint gives
'b' does not support item assignment
in line 13. But Python runs the program without any problem.
Same issue with np.full_like(), np.empty_like(), np.ones_like().
Expected behavior
No pylint error.
Workaround: In line 5, change to b = np.array(np.zeros_like(a)).
pylint --version output
pylint 2.2.2
astroid 2.1.0
Python 3.7.1
qualiaa, showgood163, spdjudd, andrelandgraf, madebyollin and 5 more
Metadata
Metadata
Assignees
Labels
Bug 🪲Needs astroid Brain 🧠Needs a brain tip in astroid (then an astroid upgrade)Needs a brain tip in astroid (then an astroid upgrade)