-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
When I pylinted a script contains numpy.complex array, E1137 appeared on correct code, and not in incorrect code.
Steps to reproduce
"""
This demonstrates numpy complex E1137 error
"""
# pylint: disable=C0103
# pylint: disable=W0702
import numpy as np
# Create a numpy complex array
comp_zeros = np.zeros(2, dtype=np.complex)
print(comp_zeros)
# Correct assignment
try:
comp_zeros.imag[0] = 1
comp_zeros.real[1] = 2
except:
print("Exception in correct assignment!")
finally:
print(comp_zeros)
# Incorrect assignment
try:
comp_zeros[0].imag = 3
comp_zeros[1].real = 4
except:
print("Exception in incorrect assignment!")
finally:
print(comp_zeros)Current behavior
I saved above script in test.py.
Script Output
$ python test.py
[0.+0.j 0.+0.j]
[0.+1.j 2.+0.j]
Exception in incorrect assignment!
[0.+1.j 2.+0.j]Lint Output
$ python -m pylint test.py
************* Module test
test.py:15:4: E1137: 'comp_zeros.imag' does not support item assignment (unsupported-assignment-operation)
test.py:16:4: E1137: 'comp_zeros.real' does not support item assignment (unsupported-assignment-operation)
------------------------------------------------------------------
Your code has been rated at 4.12/10Expected behavior
I expected E1137 to be appeared in line 24 and 25 (incorrect code).
Lint Output
test.py:24:4: E1137: 'comp_zeros[0].imag' does not support item assignment (unsupported-assignment-operation)
test.py:25:4: E1137: 'comp_zeros[1].real' does not support item assignment (unsupported-assignment-operation)
Versions
pylint 2.4.4
astroid 2.3.3
Python 3.7.5 (tags/v3.7.5:5c02a39a0b, Oct 15 2019, 01:31:54) [MSC v.1916 64 bit (AMD64)]
and
$ pip show numpy
Name: numpy
Version: 1.18.0
... (omitted)Metadata
Metadata
Assignees
Labels
No labels