本文介绍了官方缩写:import scipy as sp/sc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我都看过:

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 文档的链接实际上并没有指定 sp 而不是 sc.

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()

就个人而言,我总是使用

Personally, I always use

import scipy.fftpack

并忍受稍长的函数调用

scipy.fftpack.fft(data)

这样我就知道函数的来源了.

This way I know where the functions are coming from.

这篇关于官方缩写:import scipy as sp/sc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 07:44
查看更多