Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Official abbreviation for: import scipy as sp/sc

I've seen both:

import scipy as sp 

and:

import scipy as sc 

Is there an official preference listed anywhere?

For example, in the Introduction of the Scipy documentation, it is recommended to

import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt 

but a similar abbreviation is not offered for the Scipy package.

In this question, sp is recommended, but the link to the Scipy docs doesn't actually specify sp over sc.

like image 434
DanHickstein Avatar asked Mar 15 '16 14:03

DanHickstein


People also ask

What is SciPy short for?

SciPy stands for Scientific Python. It provides more utility functions for optimization, stats and signal processing. Like NumPy, SciPy is open source so we can use it freely.

What do people import SciPy?

Official abbreviation for: import scipy as sp/sc.

How do I import a SciPy library?

Install SciPy using the pip command Python consists of pip command which is an official package installer. It is a package manager, we can install, delete, or update any package. We need to install pip for using the pip command. Once the requirement is satisfied we can use the pip command in terminal.

Why do we import SciPy in Python?

SciPy is a collection of mathematical algorithms and convenience functions built on the NumPy extension of Python. It adds significant power to the interactive Python session by providing the user with high-level commands and classes for manipulating and visualizing data.


1 Answers

The "official" answer, according to the Scipy documentation, is that there is really no reason to ever

import 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 

then, functions can be called with

fftpack.fft() 

Personally, I always use

import scipy.fftpack 

and live with the slightly longer function call

scipy.fftpack.fft(data) 

This way I know where the functions are coming from.

like image 52
DanHickstein Avatar answered Sep 18 '22 08:09

DanHickstein