ipy_profile_scipy.py
29 lines
| 681 B
| text/x-python
|
PythonLexer
Fernando Perez
|
r1227 | """ IPython 'scipy' profile, preloads NumPy and SciPy. | ||
vivainio
|
r680 | |||
Fernando Perez
|
r1227 | This profile loads the math/cmath modules as well as all of numpy and scipy. | ||
vivainio
|
r680 | |||
Fernando Perez
|
r1227 | It exposes numpy and scipy via the 'np' and 'sp' shorthands as well for | ||
convenience. | ||||
vivainio
|
r680 | """ | ||
Brian Granger
|
r2027 | from IPython.core import ipapi | ||
vivainio
|
r680 | import ipy_defaults | ||
def main(): | ||||
Brian Granger
|
r2027 | ip = ipapi.get() | ||
vivainio
|
r680 | |||
try: | ||||
Fernando Perez
|
r1227 | ip.ex("import math,cmath") | ||
vivainio
|
r680 | ip.ex("import numpy") | ||
fperez
|
r763 | ip.ex("import scipy") | ||
Fernando Perez
|
r1227 | |||
ip.ex("import numpy as np") | ||||
ip.ex("import scipy as sp") | ||||
vivainio
|
r680 | ip.ex("from numpy import *") | ||
fperez
|
r763 | ip.ex("from scipy import *") | ||
Fernando Perez
|
r1227 | |||
vivainio
|
r680 | except ImportError: | ||
Fernando Perez
|
r1227 | print "Unable to start scipy profile, are numpy and scipy installed?" | ||
vivainio
|
r680 | |||
fperez
|
r763 | main() | ||