PEP 8: Comparison To True Should Be 'if Cond Is True:' Or 'if Cond:'
PyCharm is throwing a warning when I do np.where(temp == True) My full code: from numpy import where, array a = array([[0.4682], [0.5318]]) b = array([[0.29828851, 0., 0.28676873,
Solution 1:
Don't compare boolean against boolean.
You should check if is True or false.
b == true
if b: # If b is True
do something
In your case
temp = b > 1.1*a
pos = where(temp)
Here some explanations
Solution 2:
As per the PEP8 Guidelines in Python, comparing things to True is not a preferred pattern.
temp = True
pcos = where(temp)
If the 'temp' is assigned to be false, still specifying only 'temp' inside a conditional statement will result True. For instance:
temp = False
pros = while(temp) # if or while condition
NOTE: If your code doesn't follow PEP8, this case will not give any error.
Post a Comment for "PEP 8: Comparison To True Should Be 'if Cond Is True:' Or 'if Cond:'"