Ticket #8988: trac_8988_doctest_fix_for_symbolic_random_tests.patch

File trac_8988_doctest_fix_for_symbolic_random_tests.patch, 3.3 KB (added by novoselt, 12 years ago)

Apply after the main patch. Broken doctests are fixed by setting random seed.

  • sage/symbolic/random_tests.py

    # HG changeset patch
    # User Andrey Novoseltsev <novoselt@gmail.com>
    # Date 1275104922 21600
    # Node ID 45b1d68f6a9f3216fa6bb7b7895d331603051ff6
    # Parent  54a7d37beffcfe497640033276b3ec0b18b4c69a
    Trac 8988: Doctest fix for sage.symbolic.random_tests.py.
    
    After applying the patch for toric varieties, one of the doctests
    in the indicated file fails. Since the output seems to be supposed
    to be "random", I think that it is OK to replace old output with
    the one that I get now.
    
    Actually, as of 4.4.4alpha0 two of the random doctest fail. Following
    a suggestion on sage-devel, the random seed is set expicitly before
    the breaking test to avoid changes in the future.
    
    diff -r 54a7d37beffc -r 45b1d68f6a9f sage/symbolic/random_tests.py
    a b  
    1919full_unary = [(0.8, operator.neg), (0.2, operator.inv)]
    2020full_functions = [(1.0, f, f.number_of_arguments())
    2121        for f in sage.symbolic.pynac.symbol_table['functions'].values()
    22             if hasattr(f, 'number_of_arguments') and 
     22            if hasattr(f, 'number_of_arguments') and
    2323                f.number_of_arguments() > 0 ]
    2424full_nullary = [(1.0, c) for c in [pi, e]] + [(0.05, c) for c in
    2525        [golden_ratio, log2, euler_gamma, catalan, khinchin, twinprime,
     
    119119
    120120    This is an approximation to IntegerVectors(n, length).random_element().
    121121    That gives values uniformly at random, but might be slow; this
    122     routine is not uniform, but should always be fast. 
     122    routine is not uniform, but should always be fast.
    123123
    124124    (This routine is uniform if *length* is 1 or 2; for longer vectors,
    125125    we prefer approximately balanced vectors, where all the values
     
    206206    EXAMPLES::
    207207
    208208        sage: from sage.symbolic.random_tests import *
     209        sage: set_random_seed(20100617)
    209210        sage: random_expr(50, nvars=3, coeff_generator=CDF.random_element)
    210         arctanh(sinh(-1/erf(-((2.62756608636 + 1.20798164491*I)*v3 + (2.62756608636 + 1.20798164491*I)*e)*pi*v1) + csch((-0.708874026302 - 0.954135400334*I)*v3) - elliptic_pi(0.520184609653 - 0.734276246499*I, v3, pi)))^(-elliptic_f((v2^2 + (0.067987275089 + 1.08529153495*I)*v3)^(-v1 - v3), (5.29385548262 + 2.57440711353*I)*e/arccoth((-0.615761347729 - 0.529231982037*I)*kronecker_delta(-0.436810529675 + 0.736945423566*I, v2))))
     211        arcsin((v3 - 0.321782859199 + 0.136886898231*I)*arccsc(arcsech(-coth((-0.716600449499 + 0.354051910735*I)*e))) + (-0.162207906601 + 0.340645421567*I)*v1*v3/v2 - dirac_delta(-csch(arccot((0.53719743455 - 0.867278323703*I)*(pi + 0.0263373398975 - 0.241191385174*I)*(-0.856855986898 + 0.637612641177*I)^v1/v1))^(pi/elliptic_ec(0.0140116979246 + 0.0312629832944*I))) - 0.458596547335 - 0.165726008965*I)
    211212        sage: random_expr(5, verbose=True)
    212         About to apply <built-in function mul> to [v1, v1]
    213         About to apply <built-in function add> to [-1/3, v1]
    214         About to apply <built-in function add> to [v1^2, v1 - 1/3]
    215         v1^2 + v1 - 1/3
     213        About to apply <built-in function neg> to [e]
     214        About to apply exp to [-1]
     215        About to apply <built-in function add> to [-e, e^(-1)]
     216        e^(-1) - e
    216217    """
    217218    vars = [(1.0, sage.calculus.calculus.var('v%d' % (n+1))) for n in range(nvars)]
    218219    if ncoeffs is None: