-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
False positive: "Does not support item assignment" error with np.zeros_like #2747
Comments
Thanks for the report! |
@Max16hr the bug arises because of a lack of some dunder methods (such as |
This bug has not been fixed, I can reproduce the same behavior. |
@VasLem thanks for your remark. |
Here is an example arr1 = np.array([1,2,3])
arr2 = np.ones_like(arr1, dtype=np.uint8)
arr2[arr1 >= 2] = 255
print(arr2)
# [ 1 255 255] Line 3 : |
There are still bugs with pylint. Here is my example:
In line 18: |
Currently a bug with assigning to arrays created with `*_like(arr)` ref: pylint-dev/pylint#2747
@olivbau |
@DungMinhDao |
Is there any workaround? I could get rid of similar errors by adding numpy.ndarray to the --ignored-classes. Pylint seems to think the return of zeros_like() is a tuple though.. |
@RichardHuenermann you are right. With the current version of |
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:.
Current behavior
Pylint gives
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
The text was updated successfully, but these errors were encountered: