I use scipy for mathematical operation (such as log10()) and numpy for array creation/operations (such as np.zeros()). Right now, my code starts with: import numpy as np What is the recommended way to work with SciPy and NumPy? Being a scientist, sqrt(-1) should return a complex number, so I'm inclined to go with SciPy only. On the other hand, SciPy imports every Numpy functions in its main namespace, such that scipy.array() is the same thing as numpy.array() ( see this question), so NumPy should only be used when SciPy is not being used, as they are duplicates. In some cases, the public API is one level deeper. So NumPy should be used for array operation and SciPy for everything else. from scipy import optimize result optimize.curvefit(.) This form of importing submodules is preferred for all submodules except scipy.io (because io is also the name of a module in the Python stdlib): from scipy import interpolate from scipy import integrate import scipy.io as spio. I know there is no strict guideline and I can do it the way I want, but from time to time, I still find contradictory instructions.įor example, I've read somewhere that NumPy is meant to only implement the array object, while SciPy is there for every other scientific algorithms. In an effort to clean up my code, I have been looking for a standard convention for importing SciPy and NumPy in my programs. I trust you'll let me know if I missed something! Notice: I checked for duplicate and nothing clearly answers my question.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |