Ticket #11043: 11043-lazy-plot-again.patch

File 11043-lazy-plot-again.patch, 16.3 KB (added by robertwb, 10 years ago)

apply only this patch

  • sage/all.py

    # HG changeset patch
    # User Robert Bradshaw <robertwb@math.washington.edu>
    # Date 1314117592 25200
    # Node ID 80b98dac6a5572159d2b4aa6deb4a78e34bc76f7
    # Parent  2a2abbcad325ccca9399981ceddf5897eb467e64
    #11043 - lazy plot import
    
    diff -r 2a2abbcad325 -r 80b98dac6a55 sage/all.py
    a b  
    7373from time                import sleep
    7474
    7575from sage.misc.all       import *         # takes a while
     76from sage.misc.lazy_import import lazy_import
    7677
    7778from sage.misc.sh import sh
    7879
     
    124125
    125126from sage.quadratic_forms.all import *
    126127
    127 from sage.gsl.all        import *
     128lazy_import("sage.gsl.all", "*", overwrite=False)
    128129
    129130from sage.games.all      import *
    130131
     
    161162#after a few releases, and this code should be removed.
    162163#--Mike Hansen 9/25/2008
    163164message = "\nUsing %(name)s from the top level is deprecated since it was designed to be used by developers rather than end users.\nIt most likely does not do what you would expect it to do.  If you really need to use it, import it from the module that it is defined in."
     165from sage.misc.lazy_import import LazyImport
    164166sage.misc.misc.deprecated_callable_import(None, globals(), locals(),
    165                                           [name for name in globals().keys()
    166                                            if name.startswith('is_') and name[3].isupper()], message)
     167                                          [name for name, value in globals().items()
     168                                           if name.startswith('is_') and name[3].isupper() and type(value) is not LazyImport], message)
    167169
    168170del message, name
    169171
  • sage/calculus/all.py

    diff -r 2a2abbcad325 -r 80b98dac6a55 sage/calculus/all.py
    a b  
    1515
    1616from var import (var, function, clear_vars)
    1717
    18 from riemann import Riemann_Map
     18from sage.misc.lazy_import import lazy_import
     19lazy_import("riemann", "Riemann_Map")
    1920
    2021from interpolators import polygon_spline, complex_cubic_spline
    2122
  • sage/combinat/e_one_star.py

    diff -r 2a2abbcad325 -r 80b98dac6a55 sage/combinat/e_one_star.py
    a b  
    211211from sage.combinat.words.morphism import WordMorphism
    212212from sage.matrix.constructor import matrix
    213213from sage.modules.free_module_element import vector
    214 from sage.plot.plot import Graphics
    215 from sage.plot.plot import rainbow
    216 from sage.plot.colors import Color
    217 from sage.plot.polygon import polygon
    218 from sage.plot.line import line
    219 from sage.rings.integer_ring import ZZ
     214from sage.plot.all import Graphics, rainbow, Color, polygon, line
     215from sage.rings.all import ZZ
    220216from sage.misc.latex import LatexExpr
    221217from sage.misc.lazy_attribute import lazy_attribute
    222218from sage.misc.cachefunc import cached_method
  • sage/combinat/words/paths.py

    diff -r 2a2abbcad325 -r 80b98dac6a55 sage/combinat/words/paths.py
    a b  
    183183from sage.combinat.words.abstract_word import Word_class
    184184from sage.combinat.words.word import FiniteWord_class
    185185from sage.combinat.words.alphabet import OrderedAlphabet
    186 from sage.plot.plot import arrow, line, polygon, point, Graphics
     186from sage.plot.all import arrow, line, polygon, point, Graphics
    187187from sage.modules.free_module_element import vector
    188188from sage.rings.integer import Integer
    189189from sage.rings.all import ZZ, RR, QuadraticField
  • sage/databases/database.py

    diff -r 2a2abbcad325 -r 80b98dac6a55 sage/databases/database.py
    a b  
    6666from sage.misc.misc import tmp_filename
    6767from sage.structure.sage_object import SageObject
    6868import sage.server.support
    69 from sage.plot.plot import plot
     69from sage.plot.all import plot
    7070from sage.graphs.graph import Graph
    7171
    7272
  • sage/functions/orthogonal_polys.py

    diff -r 2a2abbcad325 -r 80b98dac6a55 sage/functions/orthogonal_polys.py
    a b  
    308308#*****************************************************************************
    309309
    310310import copy
    311 import sage.plot.plot
    312311import sage.interfaces.all
    313312from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
    314313from sage.rings.rational_field import RationalField
  • sage/functions/piecewise.py

    diff -r 2a2abbcad325 -r 80b98dac6a55 sage/functions/piecewise.py
    a b  
    6868#                  http://www.gnu.org/licenses/
    6969#*****************************************************************************
    7070
    71 import sage.plot.plot
    7271import sage.interfaces.all
    7372from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
    7473from sage.rings.rational_field import RationalField
  • sage/functions/special.py

    diff -r 2a2abbcad325 -r 80b98dac6a55 sage/functions/special.py
    a b  
    382382#*****************************************************************************
    383383
    384384import copy
    385 from sage.plot.plot import plot
     385from sage.plot.all import plot
    386386import sage.interfaces.all
    387387from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
    388388from sage.rings.rational_field import RationalField
  • sage/geometry/lattice_polytope.py

    diff -r 2a2abbcad325 -r 80b98dac6a55 sage/geometry/lattice_polytope.py
    a b  
    107107from sage.misc.all import tmp_filename
    108108from sage.misc.misc import deprecation
    109109from sage.modules.all import vector
    110 from sage.plot.plot import hue
    111 from sage.plot.plot3d.index_face_set import IndexFaceSet
    112 from sage.plot.plot3d.all import line3d, point3d
    113 from sage.plot.plot3d.shapes2 import text3d
    114 from sage.plot.plot3d.tachyon import Tachyon
     110from sage.plot.all import hue
    115111from sage.rings.all import Integer, ZZ, QQ, gcd, lcm
    116112from sage.sets.set import Set_generic
    117113from sage.structure.all import Sequence
     
    24322428            sage: m = matrix([[0,0,0],[0,1,1],[1,0,1],[1,1,0]]).transpose()
    24332429            sage: p = LatticePolytope(m, compute_vertices=True)
    24342430            sage: p.plot3d()
    2435         """       
     2431        """
     2432        from sage.plot.plot3d.index_face_set import IndexFaceSet
     2433        from sage.plot.plot3d.all import line3d, point3d
     2434        from sage.plot.plot3d.shapes2 import text3d
    24362435        dim = self.dim()       
    24372436        amb_dim = self.ambient_dim()
    24382437        if dim > 3:
  • sage/graphs/graph_coloring.py

    diff -r 2a2abbcad325 -r 80b98dac6a55 sage/graphs/graph_coloring.py
    a b  
    1717
    1818from sage.combinat.matrices.dlxcpp import DLXCPP
    1919from sage.all import Matrix, vector, QQ
    20 from sage.plot.colors import rainbow
     20from sage.plot.all import rainbow
    2121from chrompoly import chromatic_polynomial
    2222from graph_generators import GraphGenerators
    2323
  • sage/groups/perm_gps/cubegroup.py

    diff -r 2a2abbcad325 -r 80b98dac6a55 sage/groups/perm_gps/cubegroup.py
    a b  
    107107from sage.rings.finite_rings.constructor import FiniteField as GF
    108108from sage.rings.arith import factor
    109109from sage.groups.abelian_gps.abelian_group import AbelianGroup
    110 from sage.plot.polygon import polygon
    111 from sage.plot.text import text
     110from sage.plot.all import polygon, text
    112111pi = RDF.pi()
    113112
    114113
    115 from sage.plot.plot3d.shapes import Box
    116 from sage.plot.plot3d.texture import Texture
    117 
    118114####################### predefined colors ##################
    119115
    120116named_colors = {
     
    10301026       
    10311027
    10321028    def cubie(self, size, gap, x,y,z, colors, stickers=True):
     1029        from sage.plot.plot3d.shapes import Box
    10331030        sides = cubie_face_list[x,y,z]
    10341031        t = 2*size+gap
    10351032        my_colors = [colors[sides[i]+6] for i in range(6)]
     
    10481045            sage: C.plot3d()
    10491046            sage: C.plot()
    10501047        """
     1048        from sage.plot.plot3d.shapes import Box
    10511049        while len(self.colors) < 7:
    10521050            self.colors.append((.1, .1, .1))
     1051        from sage.plot.plot3d.texture import Texture
    10531052        side_colors = [Texture(color=c, ambient=.75) for c in self.colors]
    10541053        start_colors = sum([[c]*8 for c in side_colors], [])
    10551054        facets = self._group.facets(self._state)
  • sage/gsl/integration.pyx

    diff -r 2a2abbcad325 -r 80b98dac6a55 sage/gsl/integration.pyx
    a b  
    2222include 'gsl.pxi'
    2323
    2424import sage.rings.complex_double
    25 import sage.plot.plot
    2625import sage.gsl.interpolation
    2726
    2827from sage.ext.fast_eval cimport FastDoubleFunc
  • sage/media/wav.py

    diff -r 2a2abbcad325 -r 80b98dac6a55 sage/media/wav.py
    a b  
    2828import os
    2929import wave
    3030
    31 from sage.plot.plot import list_plot
     31from sage.plot.all import list_plot
    3232from sage.structure.sage_object import SageObject
    3333from sage.misc.all import srange
    3434from sage.misc.html import html
  • sage/misc/lazy_import.pyx

    diff -r 2a2abbcad325 -r 80b98dac6a55 sage/misc/lazy_import.pyx
    a b  
    791791        sage: 'EllipticCurve' in get_star_imports('sage.schemes.all')
    792792        True
    793793    """
    794     global star_imports
     794    global star_imports, _sage_all_import_done
    795795    if star_imports is None:
    796796        cache_file = get_cache_file()
    797797        if os.path.exists(cache_file):
     
    801801    try:
    802802        return star_imports[module_name]
    803803    except KeyError:
     804        all_done = _sage_all_import_done
     805        _sage_all_import_done = True # so that checks pass
    804806        module = __import__(module_name, {}, {}, ["*"])
     807        _sage_all_import_done = all_done
    805808        if hasattr(module, "__all__"):
    806809            all = module.__all__
    807810        else:
    808811            all = [key for key in dir(module) if key[0] != "_"]
    809812        star_imports[module_name] = all
    810813        return all
     814
     815# Utility functions for asserting that things stay lazily imported.
     816
     817_sage_all_import_done = False
     818
     819def check_lazy(module_name = None):
     820    """
     821    Used to assert lazily imported modules don't actually get imported
     822    during the import of sage.all is done.
     823   
     824    TESTS::
     825   
     826        sage: from sage.misc.lazy_import import check_lazy
     827        sage: check_lazy("foo")
     828        True
     829        sage: sage.misc.lazy_import._sage_all_import_done = False
     830        sage: check_lazy("foo")
     831        False
     832        sage: sage.misc.lazy_import._sage_all_import_done = True
     833        sage: check_lazy("foo")
     834        True
     835    """
     836    if module_name is None:
     837        module_name = inspect.currentframe().f_globals['__name__']
     838    return _sage_all_import_done
  • sage/modular/overconvergent/genus0.py

    diff -r 2a2abbcad325 -r 80b98dac6a55 sage/modular/overconvergent/genus0.py
    a b  
    185185from sage.modules.all       import vector
    186186from sage.modules.module    import Module_old
    187187from sage.structure.element import Vector, ModuleElement
    188 from sage.plot.plot         import plot
     188from sage.plot.all          import plot
    189189from sage.rings.all         import (O, Infinity, ZZ, QQ, pAdicField, PolynomialRing, PowerSeriesRing, is_pAdicField)
    190190import weakref
    191191
  • sage/plot/all.py

    diff -r 2a2abbcad325 -r 80b98dac6a55 sage/plot/all.py
    a b  
    1 from plot import (Graphics, plot,
    2                   graphics_array,
    3                   list_plot, parametric_plot,
    4                   polar_plot,
    5                   is_Graphics,
    6                   show_default)
    7 
    8 from line import line, line2d
    9 from arrow import arrow, arrow2d
    10 from bar_chart import bar_chart
    11 from bezier_path import bezier_path
    12 from scatter_plot import scatter_plot
    13 from disk import disk
    14 from point import point, points, point2d
    15 from matrix_plot import matrix_plot
    16 from plot_field import plot_vector_field, plot_slope_field
    17 from text import text
    18 from polygon import polygon, polygon2d
    19 from circle import circle
    20 from ellipse import ellipse
    21 from contour_plot import contour_plot, implicit_plot, region_plot
    22 from density_plot import density_plot
    23 from complex_plot import complex_plot
    24 from arc import arc
    25 
    26 from animate import Animation as animate
    27 
    28 from plot3d.tachyon import Tachyon
    29 
    30 from colors import Color, hue, rainbow, colors, colormaps
    31 
    32 from step import plot_step_function
     1from sage.misc.lazy_import import lazy_import
     2lazy_import("sage.plot.all_nonlazy", "*", overwrite=False)
     3import sage.misc.lazy_import
  • new file sage/plot/all_nonlazy.py

    diff -r 2a2abbcad325 -r 80b98dac6a55 sage/plot/all_nonlazy.py
    - +  
     1import sage.misc.lazy_import
     2assert sage.misc.lazy_import.check_lazy()
     3
     4from plot import (Graphics, plot,
     5                  graphics_array,
     6                  list_plot, parametric_plot,
     7                  polar_plot,
     8                  is_Graphics,
     9                  show_default)
     10
     11from line import line, line2d
     12from arrow import arrow, arrow2d
     13from bar_chart import bar_chart
     14from bezier_path import bezier_path
     15from scatter_plot import scatter_plot
     16from disk import disk
     17from point import point, points, point2d
     18from matrix_plot import matrix_plot
     19from plot_field import plot_vector_field, plot_slope_field
     20from text import text
     21from polygon import polygon, polygon2d
     22from circle import circle
     23from ellipse import ellipse
     24from contour_plot import contour_plot, implicit_plot, region_plot
     25from density_plot import density_plot
     26from complex_plot import complex_plot
     27from arc import arc
     28
     29from animate import Animation as animate
     30
     31from plot3d.tachyon import Tachyon
     32
     33from colors import Color, hue, rainbow, colors, colormaps
     34
     35from step import plot_step_function
  • sage/plot/plot3d/all.py

    diff -r 2a2abbcad325 -r 80b98dac6a55 sage/plot/plot3d/all.py
    a b  
    1 
    2 from plot3d            import plot3d, cylindrical_plot3d, spherical_plot3d, Spherical, SphericalElevation, Cylindrical
    3 from parametric_plot3d import parametric_plot3d
    4 from plot_field3d      import plot_vector_field3d
    5 from implicit_plot3d   import implicit_plot3d
    6 from list_plot3d       import list_plot3d
    7 from revolution_plot3d import revolution_plot3d
    8 
    9 from platonic          import tetrahedron, cube, octahedron, dodecahedron, icosahedron
    10 
    11 from shapes2           import sphere, line3d, polygon3d, point3d, text3d, bezier3d
    12 
    13 from shapes            import arrow3d
    14 
    15 #from shapes import Box, ColorCube, Cone, Cylinder, LineSegment, Arrow, Sphere, Torus, Text as Text3D
    16 #from parametric_surface import ParametricSurface, MobiusStrip
    17 #from plot3d import plot3d, axes as axes3d
    18 
    19 
    20 
     1from sage.misc.lazy_import import lazy_import
     2lazy_import("sage.plot.plot3d.all_nonlazy", "*", overwrite=False)
     3import sage.misc.lazy_import
  • new file sage/plot/plot3d/all_nonlazy.py

    diff -r 2a2abbcad325 -r 80b98dac6a55 sage/plot/plot3d/all_nonlazy.py
    - +  
     1
     2from plot3d            import plot3d, cylindrical_plot3d, spherical_plot3d, Spherical, SphericalElevation, Cylindrical
     3from parametric_plot3d import parametric_plot3d
     4from plot_field3d      import plot_vector_field3d
     5from implicit_plot3d   import implicit_plot3d
     6from list_plot3d       import list_plot3d
     7from revolution_plot3d import revolution_plot3d
     8
     9from platonic          import tetrahedron, cube, octahedron, dodecahedron, icosahedron
     10
     11from shapes2           import sphere, line3d, polygon3d, point3d, text3d, bezier3d
     12
     13from shapes            import arrow3d
     14
     15#from shapes import Box, ColorCube, Cone, Cylinder, LineSegment, Arrow, Sphere, Torus, Text as Text3D
     16#from parametric_surface import ParametricSurface, MobiusStrip
     17#from plot3d import plot3d, axes as axes3d
     18
     19
     20