# HG changeset patch
# User Robert Bradshaw <robertwb@math.washington.edu>
# Date 1301130596 25200
# Node ID e3648b27897bf51603fb0f502a95ada7b909f1ae
# Parent 5e2f50b4e8c9e7d23b74ff8d6ae3701bc314f9ce
#11043 - Lazily import plot, numpy, etc. to speed up startup.
diff -r 5e2f50b4e8c9 -r e3648b27897b sage/all.py
a
|
b
|
|
1 | 1 | """ |
2 | 2 | all.py -- much of sage is imported into this module, so you don't |
3 | 3 | have to import everything individually. |
| 4 | |
| 5 | TESTS: |
| 6 | |
| 7 | Make sure numpy is not imported at startup:: |
| 8 | |
| 9 | sage: os.system('''sage -c "assert 'numpy' not in sys.modules"''') == 0 |
| 10 | True |
4 | 11 | """ |
5 | 12 | |
6 | 13 | from __future__ import with_statement |
… |
… |
|
96 | 103 | from sage.functions.all import * |
97 | 104 | from sage.calculus.all import * |
98 | 105 | |
99 | | from sage.server.all import * |
| 106 | lazy_import("sage.server.all", "*", overwrite=False) |
100 | 107 | import sage.tests.all as tests |
101 | 108 | |
102 | 109 | from sage.crypto.all import * |
103 | 110 | import sage.crypto.mq as mq |
104 | 111 | |
105 | | from sage.plot.all import * |
106 | | from sage.plot.plot3d.all import * |
| 112 | lazy_import("sage.plot.all", "*", overwrite=False) |
| 113 | lazy_import("sage.plot.plot3d.all", "*", overwrite=False) |
107 | 114 | |
108 | 115 | from sage.coding.all import * |
109 | 116 | from sage.combinat.all import * |
110 | 117 | |
111 | 118 | lazy_import("sage.lfunctions.all", "*", overwrite=False) |
112 | 119 | |
113 | | from sage.geometry.all import * |
114 | | from sage.geometry.triangulation.all import * |
| 120 | lazy_import("sage.geometry.all", "*", overwrite=False) |
| 121 | lazy_import("sage.geometry.triangulation.all", "*", overwrite=False) |
115 | 122 | |
116 | 123 | from sage.homology.all import * |
117 | 124 | |
118 | 125 | from sage.quadratic_forms.all import * |
119 | 126 | |
120 | | from sage.gsl.all import * |
| 127 | lazy_import("sage.gsl.all", "*", overwrite=False) |
121 | 128 | |
122 | 129 | from sage.games.all import * |
123 | 130 | |
… |
… |
|
130 | 137 | from sage.stats.all import * |
131 | 138 | import sage.stats.all as stats |
132 | 139 | |
133 | | import sage.finance.all as finance |
| 140 | lazy_import("sage.finance", "all", "finance", overwrite=False) |
134 | 141 | |
135 | 142 | import sage.interacts as interacts |
136 | 143 | |
diff -r 5e2f50b4e8c9 -r e3648b27897b sage/calculus/all.py
a
|
b
|
|
| 1 | from sage.misc.lazy_import import lazy_import |
| 2 | |
1 | 3 | from calculus import maxima as maxima_calculus |
2 | 4 | from calculus import (laplace, inverse_laplace, |
3 | 5 | limit, lim) |
… |
… |
|
15 | 17 | |
16 | 18 | from var import (var, function, clear_vars) |
17 | 19 | |
18 | | from riemann import Riemann_Map |
19 | | |
20 | | from interpolators import polygon_spline, complex_cubic_spline |
| 20 | lazy_import('sage.calculus.riemann', 'Riemann_Map') |
| 21 | lazy_import('sage.calculus.interpolators', ('polygon_spline', 'complex_cubic_spline')) |
21 | 22 | |
22 | 23 | from sage.modules.all import vector |
23 | 24 | |
diff -r 5e2f50b4e8c9 -r e3648b27897b sage/calculus/desolvers.py
a
|
b
|
|
57 | 57 | ########################################################################## |
58 | 58 | |
59 | 59 | from sage.interfaces.maxima import MaximaElement, Maxima |
60 | | from sage.plot.all import line |
61 | 60 | from sage.symbolic.expression import is_SymbolicEquation |
62 | 61 | from sage.symbolic.ring import is_SymbolicVariable |
63 | 62 | from sage.calculus.functional import diff |
… |
… |
|
1043 | 1042 | x00 = x01 |
1044 | 1043 | t00 = t00 + h |
1045 | 1044 | soln.append([t00,x00,y00]) |
| 1045 | from sage.plot.all import line |
1046 | 1046 | Q1 = line([[x[0],x[1]] for x in soln], rgbcolor=(1/4,1/8,3/4)) |
1047 | 1047 | Q2 = line([[x[0],x[2]] for x in soln], rgbcolor=(1/2,1/8,1/4)) |
1048 | 1048 | return [Q1,Q2] |
diff -r 5e2f50b4e8c9 -r e3648b27897b sage/functions/prime_pi.pyx
a
|
b
|
|
28 | 28 | |
29 | 29 | from sage.rings.integer import Integer |
30 | 30 | from sage.rings.fast_arith import prime_range |
31 | | import sage.plot.all |
32 | 31 | |
33 | 32 | cdef extern from "math.h": |
34 | 33 | double sqrt(double) |
diff -r 5e2f50b4e8c9 -r e3648b27897b sage/functions/spike_function.py
a
|
b
|
|
2 | 2 | |
3 | 3 | import math |
4 | 4 | |
5 | | from sage.plot.all import line |
6 | 5 | from sage.modules.free_module_element import vector |
7 | 6 | from sage.rings.all import RDF |
8 | 7 | |
… |
… |
|
249 | 248 | new_x = xmax |
250 | 249 | v.append( (new_x, 0) ) |
251 | 250 | x = new_x |
| 251 | from sage.plot.all import line |
252 | 252 | L = line(v, **kwds) |
253 | 253 | L.xmin(xmin-1); L.xmax(xmax) |
254 | 254 | return L |
diff -r 5e2f50b4e8c9 -r e3648b27897b sage/functions/transcendental.py
a
|
b
|
|
37 | 37 | from sage.symbolic.function import GinacFunction, BuiltinFunction, is_inexact |
38 | 38 | from sage.symbolic.ring import SR |
39 | 39 | |
40 | | import sage.plot.all |
41 | | |
42 | 40 | CC = complex_field.ComplexField() |
43 | 41 | I = CC.gen(0) |
44 | 42 | |
diff -r 5e2f50b4e8c9 -r e3648b27897b sage/gsl/dwt.pyx
a
|
b
|
|
25 | 25 | |
26 | 26 | #include 'gsl.pxi' |
27 | 27 | |
28 | | import sage.plot.all |
29 | | |
30 | 28 | #import gsl_array |
31 | 29 | #cimport gsl_array |
32 | 30 | |
… |
… |
|
137 | 135 | cdef int i |
138 | 136 | cdef double x |
139 | 137 | v = [] |
140 | | point = sage.plot.all.point |
| 138 | from sage.plot.all import point |
141 | 139 | if xmin == None: |
142 | 140 | x_min = 0 |
143 | 141 | if xmax == None: |
diff -r 5e2f50b4e8c9 -r e3648b27897b sage/gsl/fft.pyx
a
|
b
|
|
26 | 26 | |
27 | 27 | include '../ext/stdsage.pxi' |
28 | 28 | |
29 | | import sage.plot.all |
30 | | import sage.libs.pari.all |
31 | 29 | from sage.rings.integer import Integer |
32 | 30 | from sage.rings.complex_number import ComplexNumber |
33 | 31 | |
… |
… |
|
93 | 91 | cdef int i |
94 | 92 | v = [] |
95 | 93 | |
96 | | pari = sage.libs.pari.all.pari |
97 | | point = sage.plot.all.point |
| 94 | from sage.libs.pari.all import pari |
| 95 | from sage.plot.all import point |
98 | 96 | pi = pari('Pi') |
99 | 97 | s = 1/(3*pi) # so arg gets scaled between -1/3 and 1/3. |
100 | 98 | |
… |
… |
|
115 | 113 | cdef double pr_x, x, h |
116 | 114 | v = [] |
117 | 115 | |
118 | | point = sage.plot.all.point |
| 116 | from sage.plot.all import point |
119 | 117 | |
120 | 118 | for i from xmin <= i < xmax: |
121 | 119 | x = self.data[2*i] |
diff -r 5e2f50b4e8c9 -r e3648b27897b sage/plot/all.py
a
|
b
|
|
| 1 | import sage.misc.lazy_import |
| 2 | assert sage.misc.lazy_import.check_lazy() |
| 3 | |
1 | 4 | from plot import (Graphics, plot, |
2 | 5 | graphics_array, |
3 | 6 | list_plot, parametric_plot, |
diff -r 5e2f50b4e8c9 -r e3648b27897b sage/stats/all.py
a
|
b
|
|
| 1 | from sage.misc.lazy_import import lazy_import |
| 2 | |
1 | 3 | from r import (ttest) |
2 | 4 | from basic_stats import (mean, mode, std, variance, median, moving_average) |
3 | 5 | |
4 | | import hmm.all as hmm |
| 6 | lazy_import("sage.stats.hmm", "all", "hmm") |
5 | 7 | |
6 | | from sage.finance.time_series import TimeSeries |
7 | | from intlist import IntList |
| 8 | lazy_import("sage.finance.time_series", "TimeSeries") |
| 9 | lazy_import("sage.stats.intlist", "IntList") |
8 | 10 | |