Answer a question

The following line in PyCharm is flagged by on-the-fly inspection with unresolved reference errors for each import. (They are underlined red.)

from numpy import tan, arcsin, arccos, arctan

However the following imports do not cause any error/warning:

from numpy import sin, cos, arctan2, sqrt, cross, pi

The code in which I use these imports runs fine without any errors or warnings. I generally rely on PyCharm's red errors as a warning that my code is broken and will not run, but in this case PyCharm is wrong.

Why are some of numpy's functions recognized by PyCharm's introspection and others aren't?

Current Versions:

  • Windows 7 64-bit
  • Python 2.7.5
  • PyCharm 3.1.2
  • Numpy 1.8

Thanks!

Answers

The reason you are getting this is because of PyCharm's static analysis. Now, what Python does is use static skeletons (some are pre-generated and some are generated) to give you the analysis. Take a look at the pre-generated skeletons here -> https://github.com/JetBrains/python-skeletons

This might be solved, by enabling the following:

enter image description here

However, if that does not work:

enter image description here

which will block off the error, it will appear as a comment above the line.

Logo

学AI,认准AI Studio!GPU算力,限时免费领,邀请好友解锁更多惊喜福利 >>>

更多推荐