Ticket #11043: 11043-lazy-plot.patch

File 11043-lazy-plot.patch, 7.1 KB (added by robertwb, 10 years ago)
  • sage/all.py

    # 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  
    11"""
    22all.py -- much of sage is imported into this module, so you don't
    33          have to import everything individually.
     4         
     5TESTS:
     6
     7Make sure numpy is not imported at startup::
     8   
     9    sage: os.system('''sage -c "assert 'numpy' not in sys.modules"''') == 0
     10    True
    411"""
    512
    613from __future__ import with_statement
     
    96103from sage.functions.all  import *
    97104from sage.calculus.all   import *
    98105
    99 from sage.server.all     import *
     106lazy_import("sage.server.all", "*", overwrite=False)
    100107import sage.tests.all as tests
    101108
    102109from sage.crypto.all     import *
    103110import sage.crypto.mq as mq
    104111
    105 from sage.plot.all       import *
    106 from sage.plot.plot3d.all     import *
     112lazy_import("sage.plot.all", "*", overwrite=False)
     113lazy_import("sage.plot.plot3d.all", "*", overwrite=False)
    107114
    108115from sage.coding.all     import *
    109116from sage.combinat.all   import *
    110117
    111118lazy_import("sage.lfunctions.all", "*", overwrite=False)
    112119
    113 from sage.geometry.all   import *
    114 from sage.geometry.triangulation.all   import *
     120lazy_import("sage.geometry.all", "*", overwrite=False)
     121lazy_import("sage.geometry.triangulation.all", "*", overwrite=False)
    115122
    116123from sage.homology.all   import *
    117124
    118125from sage.quadratic_forms.all import *
    119126
    120 from sage.gsl.all        import *
     127lazy_import("sage.gsl.all", "*", overwrite=False)
    121128
    122129from sage.games.all      import *
    123130
     
    130137from sage.stats.all      import *
    131138import sage.stats.all as stats
    132139
    133 import sage.finance.all  as finance
     140lazy_import("sage.finance", "all", "finance", overwrite=False)
    134141
    135142import sage.interacts as interacts
    136143
  • sage/calculus/all.py

    diff -r 5e2f50b4e8c9 -r e3648b27897b sage/calculus/all.py
    a b  
     1from sage.misc.lazy_import import lazy_import
     2
    13from calculus import maxima as maxima_calculus
    24from calculus import (laplace, inverse_laplace,
    35                      limit, lim)
     
    1517
    1618from var import (var, function, clear_vars)
    1719
    18 from riemann import Riemann_Map
    19 
    20 from interpolators import polygon_spline, complex_cubic_spline
     20lazy_import('sage.calculus.riemann', 'Riemann_Map')
     21lazy_import('sage.calculus.interpolators', ('polygon_spline', 'complex_cubic_spline'))
    2122
    2223from sage.modules.all import vector
    2324
  • sage/calculus/desolvers.py

    diff -r 5e2f50b4e8c9 -r e3648b27897b sage/calculus/desolvers.py
    a b  
    5757##########################################################################
    5858
    5959from sage.interfaces.maxima import MaximaElement, Maxima
    60 from sage.plot.all import line
    6160from sage.symbolic.expression import is_SymbolicEquation
    6261from sage.symbolic.ring import is_SymbolicVariable
    6362from sage.calculus.functional import diff
     
    10431042        x00 = x01
    10441043        t00 = t00 + h
    10451044        soln.append([t00,x00,y00])
     1045    from sage.plot.all import line
    10461046    Q1 = line([[x[0],x[1]] for x in soln], rgbcolor=(1/4,1/8,3/4))
    10471047    Q2 = line([[x[0],x[2]] for x in soln], rgbcolor=(1/2,1/8,1/4))
    10481048    return [Q1,Q2]
  • sage/functions/prime_pi.pyx

    diff -r 5e2f50b4e8c9 -r e3648b27897b sage/functions/prime_pi.pyx
    a b  
    2828
    2929from sage.rings.integer import Integer
    3030from sage.rings.fast_arith import prime_range
    31 import sage.plot.all
    3231
    3332cdef extern from "math.h":
    3433    double sqrt(double)
  • sage/functions/spike_function.py

    diff -r 5e2f50b4e8c9 -r e3648b27897b sage/functions/spike_function.py
    a b  
    22
    33import math
    44
    5 from sage.plot.all import line
    65from sage.modules.free_module_element import vector
    76from sage.rings.all import RDF
    87
     
    249248                    new_x = xmax
    250249                v.append( (new_x, 0) )
    251250                x = new_x
     251        from sage.plot.all import line
    252252        L = line(v, **kwds)
    253253        L.xmin(xmin-1); L.xmax(xmax)
    254254        return L
  • sage/functions/transcendental.py

    diff -r 5e2f50b4e8c9 -r e3648b27897b sage/functions/transcendental.py
    a b  
    3737from sage.symbolic.function import GinacFunction, BuiltinFunction, is_inexact
    3838from sage.symbolic.ring import SR
    3939
    40 import sage.plot.all
    41 
    4240CC = complex_field.ComplexField()
    4341I = CC.gen(0)
    4442
  • sage/gsl/dwt.pyx

    diff -r 5e2f50b4e8c9 -r e3648b27897b sage/gsl/dwt.pyx
    a b  
    2525
    2626#include 'gsl.pxi'
    2727
    28 import sage.plot.all
    29 
    3028#import gsl_array
    3129#cimport gsl_array
    3230
     
    137135        cdef int i
    138136        cdef double x
    139137        v = []
    140         point = sage.plot.all.point
     138        from sage.plot.all import point
    141139        if xmin == None:
    142140            x_min = 0
    143141        if xmax == None:
  • sage/gsl/fft.pyx

    diff -r 5e2f50b4e8c9 -r e3648b27897b sage/gsl/fft.pyx
    a b  
    2626
    2727include '../ext/stdsage.pxi'
    2828
    29 import sage.plot.all
    30 import sage.libs.pari.all
    3129from sage.rings.integer import Integer
    3230from sage.rings.complex_number import ComplexNumber
    3331
     
    9391        cdef int i
    9492        v = []
    9593
    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
    9896        pi = pari('Pi')
    9997        s = 1/(3*pi)   # so arg gets scaled between -1/3 and 1/3.
    10098
     
    115113        cdef double pr_x, x, h
    116114        v = []
    117115
    118         point = sage.plot.all.point
     116        from sage.plot.all import point
    119117
    120118        for i from xmin <= i < xmax:
    121119            x = self.data[2*i]
  • sage/plot/all.py

    diff -r 5e2f50b4e8c9 -r e3648b27897b sage/plot/all.py
    a b  
     1import sage.misc.lazy_import
     2assert sage.misc.lazy_import.check_lazy()
     3
    14from plot import (Graphics, plot,
    25                  graphics_array,
    36                  list_plot, parametric_plot,
  • sage/stats/all.py

    diff -r 5e2f50b4e8c9 -r e3648b27897b sage/stats/all.py
    a b  
     1from sage.misc.lazy_import import lazy_import
     2
    13from r import (ttest)
    24from basic_stats import (mean, mode, std, variance, median, moving_average)
    35
    4 import hmm.all as hmm
     6lazy_import("sage.stats.hmm", "all", "hmm")
    57
    6 from sage.finance.time_series import TimeSeries
    7 from intlist import IntList
     8lazy_import("sage.finance.time_series", "TimeSeries")
     9lazy_import("sage.stats.intlist", "IntList")
    810