Relationship between SciPy and NumPy

前端 未结 8 1800
清酒与你
清酒与你 2020-11-27 09:34

SciPy appears to provide most (but not all [1]) of NumPy\'s functions in its own namespace. In other words, if there\'s a function named numpy.foo, there\'s alm

8条回答
  •  执念已碎
    2020-11-27 09:53

    In addition to the SciPy FAQ describing the duplication is mainly for backwards compatibility, it is further clarified in the NumPy documentation to say that

    Optionally SciPy-accelerated routines (numpy.dual)

    Aliases for functions which may be accelerated by Scipy.

    SciPy can be built to use accelerated or otherwise improved libraries for FFTs, linear algebra, and special functions. This module allows developers to transparently support these accelerated functions when SciPy is available but still support users who have only installed NumPy.

    For brevity, these are:

    • Linear algebra
    • FFT
    • The Modified Bessel function of the first kind, order 0

    Also, from the SciPy Tutorial:

    The top level of SciPy also contains functions from NumPy and numpy.lib.scimath. However, it is better to use them directly from the NumPy module instead.

    So, for new applications, you should prefer the NumPy version of the array operations that are duplicated in the top level of SciPy. For the domains listed above, you should prefer those in SciPy and check backward compatibility if necessary in NumPy.

    In my personal experience, most of the array functions I use exist in the top level of NumPy (except for random). However, all the domain specific routines exist in subpackages of SciPy, so I rarely use anything from the top level of SciPy.

提交回复
热议问题