3

Please consider the following code:

import numpy as np

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

Given 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 does not throw a warning:

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

Why does PyCharm treat bins as of type int in the first two versions and how and why does augmented assignment change this behavior?

I am running PyCharm 4.5.1 Community Edition on Yosemite.

MaxPowers
  • 5,235
  • 2
  • 44
  • 69
  • I see the same behavior on PyCharm 4.5.1 Professional Edition on Mavericks (OS X 10.9.5), with Python 3.4.1 (Anaconda 2.1.0) – Bryant Aug 30 '15 at 21:25
  • There are no 'view' in a second and third piece of code. How the second piece of code can generate such warning? I've checked in PyCharm 2017.1.1 for Linux and I'm right. – RomanS Aug 02 '18 at 16:10

0 Answers0