My most used NumPy/SciPy functions
I analyzed my recent Python scripts, and it appears that the most used NumPy/SciPy symbols are:
asarrayby a large margin
linspace, three times less often than
float32(that's not a function, but a type)
arange(I use it four times less often than
array(copy-by-default, much less used than
savetxt(two times less often than
Overall, the most used functions
- convert anything to array (mostly lists and nested lists)
- do simple file input-output (
- construct new arrays from the existing blocks (
roll...) and default arrays (
- do basic linear algebra (
- make common reductions (
- broadcast function application (
- define inter-element relations (
This may be useful to know when designing a custom array-like API (I still wish I had time to write a Clojure wrapper around Commons Math).
I counted only qualified and explicit imports ("import numpy as np", "from nump import foo"). I didn't count scripts which use
from ... import *. That's too much work for grep and sed. I also didn't count use of array object's methods. This would require static analysis of Python code.
Do you know tools for such an analysis?