问题描述
我都看过:
import scipy as sp
和:
import scipy as sc
在任何地方都列出了官方偏好吗?
Is there an official preference listed anywhere?
例如,在 Scipy文档简介中,建议
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
,但Scipy软件包未提供类似的缩写.
but a similar abbreviation is not offered for the Scipy package.
在此问题中,建议使用sp
,但是链接到Scipy文档的位置实际上并未在sc
上指定sp
.
In this question, sp
is recommended, but the link to the Scipy docs doesn't actually specify sp
over sc
.
推荐答案
根据 Scipy文档,是真的没有理由要
The "official" answer, according to the Scipy documentation, is that there is really no reason to ever
import scipy
因为Scipy中所有有趣的功能实际上都位于子模块中,所以不会自动导入.因此,推荐的方法是使用
since all of the interesting functions in Scipy are actually located in the submodules, which are not automatically imported. Therefore, the recommended method is to use
from scipy import fftpack
from scipy import integrate
然后,可以使用调用
fftpack.fft()
我个人一直使用
import scipy.fftpack
并使用稍长的函数调用
scipy.fftpack.fft(data)
这样我就知道功能从何而来.
This way I know where the functions are coming from.
这篇关于官方缩写为:以sp/sc形式导入scipy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!