Ticket #11714: trac_11714-only-this.patch

File trac_11714-only-this.patch, 7.6 KB (added by William Stein, 11 years ago)

fixes the import numpy issue. make ptestlong passes.

  • sage/calculus/all.py

    # HG changeset patch
    # User Julian Rueth <julian.rueth@gmail.com>
    # Date 1314295813 25200
    # Node ID dc4862938ad9b4e4f42fe46d61a774db9b9993a2
    # Parent  74bab45999b9ef99f4766788a0ecb9d9974fac88
    Trac 11714: do not load numpy on startup
    
    diff --git a/sage/calculus/all.py b/sage/calculus/all.py
    a b  
    1515
    1616from var import (var, function, clear_vars)
    1717
    18 from riemann import Riemann_Map
    19 
    20 from interpolators import polygon_spline, complex_cubic_spline
     18# We lazy_import the following modules since they import numpy which slows down sage startup
     19from sage.misc.lazy_import import lazy_import
     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/finance/all.py

    diff --git a/sage/finance/all.py b/sage/finance/all.py
    a b  
    22
    33from markov_multifractal import MarkovSwitchingMultifractal
    44
    5 from time_series import TimeSeries, autoregressive_fit
    6 
    7 from fractal import (stationary_gaussian_simulation,
    8                      fractional_gaussian_noise_simulation,
    9                      fractional_brownian_motion_simulation,
    10                      multifractal_cascade_random_walk_simulation)
    11 
    12 ## def TimeSeries(values):
    13 ##     """
    14 ##     Initialize new time series.
    15 
    16 ##     INPUT:
    17 ##         values -- integer (number of values) or an iterable of floats
    18 
    19 ##     EXAMPLES:
    20 ##     This implicity calls init.
    21 ##         sage: finance.TimeSeries([pi, 3, 18.2])
    22 ##         [3.1416, 3.0000, 18.2000]
    23 ##     """
    24 ##     # A dirty trick to avoid importing time_series (hence vector_real_double_dense)
    25 ##     # every time sage starts up, but to make sure that the finance.TimeSeries
    26 ##     # function is VERY fast.  The first time this function is called it is
    27 ##     # immediately replaced by the fast compiled version in the time_series
    28 ##     # module.
    29 ##     from time_series import TimeSeries
    30 ##     globals()['TimeSeries'] = TimeSeries
    31 ##     return TimeSeries(values)
     5# We lazy_import the following modules since they import numpy which slows down sage startup
     6from sage.misc.lazy_import import lazy_import
     7lazy_import("sage.finance.time_series", ["TimeSeries"])
     8lazy_import("sage.finance.time_series", ["autoregressive_fit"])
     9lazy_import("sage.finance.fractal", ["stationary_gaussian_simulation", "fractional_gaussian_noise_simulation", "fractional_brownian_motion_simulation", "multifractal_cascade_random_walk_simulation"])
  • sage/plot/all.py

    diff --git a/sage/plot/all.py b/sage/plot/all.py
    a b  
    2020from ellipse import ellipse
    2121from contour_plot import contour_plot, implicit_plot, region_plot
    2222from density_plot import density_plot
    23 from complex_plot import complex_plot
     23
     24from sage.misc.lazy_import import lazy_import
     25lazy_import("sage.plot.complex_plot",["complex_plot"])
     26
    2427from arc import arc
    2528
    2629from animate import Animation as animate
  • sage/plot/plot3d/all.py

    diff --git a/sage/plot/plot3d/all.py b/sage/plot/plot3d/all.py
    a b  
    22from plot3d            import plot3d, cylindrical_plot3d, spherical_plot3d, Spherical, SphericalElevation, Cylindrical
    33from parametric_plot3d import parametric_plot3d
    44from plot_field3d      import plot_vector_field3d
    5 from implicit_plot3d   import implicit_plot3d
     5
     6# We lazy_import the following modules since they import numpy which slows down sage startup
     7from sage.misc.lazy_import import lazy_import
     8lazy_import("sage.plot.plot3d.implicit_plot3d",["implicit_plot3d"])
     9
    610from list_plot3d       import list_plot3d
    711from revolution_plot3d import revolution_plot3d
    812
  • sage/stats/all.py

    diff --git a/sage/stats/all.py b/sage/stats/all.py
    a b  
    33
    44import hmm.all as hmm
    55
    6 from sage.finance.time_series import TimeSeries
    7 from intlist import IntList
    8 
     6# We lazy_import the following modules since they import numpy which slows down sage startup
     7from sage.misc.lazy_import import lazy_import
     8lazy_import("sage.finance.time_series", ["TimeSeries"])
     9lazy_import("sage.stats.intlist",["IntList"])
  • sage/stats/hmm/all.py

    diff --git a/sage/stats/hmm/all.py b/sage/stats/hmm/all.py
    a b  
    55#                  http://www.gnu.org/licenses/
    66#############################################################################
    77
    8 from hmm  import DiscreteHiddenMarkovModel
    9 
    10 from chmm import (GaussianHiddenMarkovModel,
    11                   GaussianMixtureHiddenMarkovModel)
    12 
    13 from distributions import GaussianMixtureDistribution
    14 
     8# We lazy_import the following modules since they import numpy which slows down sage startup
     9from sage.misc.lazy_import import lazy_import
     10lazy_import("sage.stats.hmm.hmm", ["DiscreteHiddenMarkovModel"])
     11lazy_import("sage.stats.hmm.chmm", ["GaussianHiddenMarkovModel","GaussianMixtureHiddenMarkovModel"])
     12lazy_import("sage.stats.hmm.distributions", ["GaussianMixtureDistribution"])
  • sage/stats/hmm/distributions.pyx

    diff --git a/sage/stats/hmm/distributions.pyx b/sage/stats/hmm/distributions.pyx
    a b  
    8686
    8787        This method must be defined in a derived class::
    8888       
     89            sage: import sage.stats.hmm.distributions
    8990            sage: sage.stats.hmm.distributions.Distribution().sample()
    9091            Traceback (most recent call last):
    9192            ...
     
    109110
    110111        This method must be defined in a derived class::
    111112
     113            sage: import sage.stats.hmm.distributions
    112114            sage: sage.stats.hmm.distributions.Distribution().prob(0)
    113115            Traceback (most recent call last):
    114116            ...
     
    239241
    240242        EXAMPLES::
    241243
    242             sage: G = sage.stats.hmm.distributions.GaussianMixtureDistribution([(.1,1,2), (.9,0,1)])
     244            sage: G = hmm.GaussianMixtureDistribution([(.1,1,2), (.9,0,1)])
    243245            sage: loads(dumps(G)) == G
    244246            True
    245247        """
     
    250252        """
    251253        EXAMPLES::
    252254
    253             sage: G = sage.stats.hmm.distributions.GaussianMixtureDistribution([(.1,1,2), (.9,0,1)])
    254             sage: H = sage.stats.hmm.distributions.GaussianMixtureDistribution([(.3,1,2), (.7,1,5)])
     255            sage: G = hmm.GaussianMixtureDistribution([(.1,1,2), (.9,0,1)])
     256            sage: H = hmm.GaussianMixtureDistribution([(.3,1,2), (.7,1,5)])
    255257            sage: G < H
    256258            True
    257259            sage: H > G
  • sage/stats/hmm/util.pyx

    diff --git a/sage/stats/hmm/util.pyx b/sage/stats/hmm/util.pyx
    a b  
    4444
    4545        EXAMPLES::
    4646
     47            sage: import sage.stats.hmm.util
    4748            sage: T = stats.TimeSeries([.1, .3, .7, .5])
    4849            sage: u = sage.stats.hmm.util.HMM_Util()
    4950            sage: u.normalize_probability_TimeSeries(T,0,3)
     
    103104
    104105        EXAMPLES::
    105106
     107            sage: import sage.stats.hmm.util
    106108            sage: u = sage.stats.hmm.util.HMM_Util()
    107109            sage: u.initial_probs_to_TimeSeries([0.1,0.2,0.9], True)
    108110            [0.0833, 0.1667, 0.7500]
     
    143145
    144146        EXAMPLES::
    145147
     148            sage: import sage.stats.hmm.util
    146149            sage: u = sage.stats.hmm.util.HMM_Util()
    147150            sage: u.state_matrix_to_TimeSeries([[.1,.7],[3/7,4/7]], 2, True)
    148151            [0.1250, 0.8750, 0.4286, 0.5714]
  • sage/tests/startup.py

    diff --git a/sage/tests/startup.py b/sage/tests/startup.py
    a b  
    88    ... else: print True   # nothing when not on sage.math
    99    True
    1010
     11Ensure that certain modules are not loaded on startup::
     12
     13    sage: sage0("'numpy' in sys.modules")
     14    False
    1115"""