Pycharm irregular attribute warning

Pay attention to the following code:

import numpy as np

r = [1, 0, -1, 0]
bins = np.fft.fft(r) / len(r)
x = bins.view(float)

      

Considering the above code, PyCharm returns this warning: Unresolved attribute reference 'view' for class 'int'

If I split line 4 into two lines like

bins = np.fft.fft(r)
bins = bins / len(r)

      

the same warning appears. Only the following warning doesn't trigger:

bins = np.fft.fft(r)
bins /= len(r)

      

Why does PyCharm consider bins

by type int

in the first two versions, and how and why does the added assignment change this behavior?

I am running PyCharm 4.5.1 Community Edition on Yosemite.

+3


source to share





All Articles