Ticket #9828: trac_9828-cython_0_13.patch

File trac_9828-cython_0_13.patch, 31.8 KB (added by mpatel, 12 years ago)

Folded sage repository patch. Apply only this patch to the sage repository.

  • sage/categories/morphism.pxd

    # HG changeset patch
    # User Mitesh Patel <qed777@gmail.com>
    # Date 1286444585 25200
    # Node ID 6217f5d97aecc3c1c09d3b35fa1142fd331d5a7b
    # Parent  bc10678f636e82f2c78203db82abccb6d6f3babf
    #9828: Upgrade to Cython 0.13
    
    * * *
    [mq]: 8_alpha_fixes.patch
    * * *
    [mq]: hudson-results
    * * *
    Use bint not bool.
    * * *
    Implicit object conversion fix.
    * * *
    Small type fixes.
    * * *
    Remove some extraneous explicit types.
    * * *
    Fix some incorrect import statements.
    * * *
    Turn off autodict generation for Cython files.
    * * *
    Explicitly type string literals as bytes objects to make Cython happy.
    * * *
    Fix setup.py for new Cython.
    
    diff --git a/sage/categories/morphism.pxd b/sage/categories/morphism.pxd
    a b cdef class Morphism(Map): 
    77
    88cdef class SetMorphism(Morphism):
    99    cdef object _function
    10     cpdef bool _eq_c_impl(left, Element right)
     10    cpdef bint _eq_c_impl(left, Element right)
  • sage/categories/morphism.pyx

    diff --git a/sage/categories/morphism.pyx b/sage/categories/morphism.pyx
    a b cdef class SetMorphism(Morphism): 
    286286        self._function = _slots['_function']
    287287        Map._update_slots(self, _slots)
    288288
    289     cpdef bool _eq_c_impl(self, Element other):
     289    cpdef bint _eq_c_impl(self, Element other):
    290290        """
    291291        Equality test
    292292
  • sage/graphs/base/c_graph.pyx

    diff --git a/sage/graphs/base/c_graph.pyx b/sage/graphs/base/c_graph.pyx
    a b cdef class Search_iterator: 
    25432543    cdef int direction
    25442544    cdef list stack
    25452545    cdef bitset_t seen
    2546     cdef bool test_out
    2547     cdef bool test_in
     2546    cdef bint test_out
     2547    cdef bint test_in
    25482548
    25492549    def __init__(self, graph, v, direction=0, reverse=False,
    25502550                 ignore_direction=False):
  • sage/graphs/cliquer.pxd

    diff --git a/sage/graphs/cliquer.pxd b/sage/graphs/cliquer.pxd
    a b cdef extern from "cliquer/cliquer.h": 
    88
    99
    1010cdef extern from "cliquer/reorder.h":
    11      cdef int *reorder_by_greedy_coloring(graph_t *g, bool weighted)
    12      cdef int *reorder_by_degree(graph_t *g, bool weighted)
     11     cdef int *reorder_by_greedy_coloring(graph_t *g, bint weighted)
     12     cdef int *reorder_by_degree(graph_t *g, bint weighted)
    1313
    1414cdef extern from "cliquer/cliquer.h":
    15      bool clique_print_time(intlevel, int i, int n, int max, double cputime, double realtime, clique_options *opts)
     15     bint clique_print_time(intlevel, int i, int n, int max, double cputime, double realtime, clique_options *opts)
    1616
    1717
    1818cdef extern from "cliquer/cl.h":
  • sage/graphs/generic_graph_pyx.pxd

    diff --git a/sage/graphs/generic_graph_pyx.pxd b/sage/graphs/generic_graph_pyx.pxd
    a b cdef class SubgraphSearch: 
    2323    cdef int **line_h_in
    2424    cdef list g_vertices
    2525    cdef int i
    26     cdef bool directed
     26    cdef bint directed
    2727
    2828
    2929cdef inline bint vectors_equal(int n, int *a, int *b)
  • sage/graphs/generic_graph_pyx.pyx

    diff --git a/sage/graphs/generic_graph_pyx.pyx b/sage/graphs/generic_graph_pyx.pyx
    a b cdef class SubgraphSearch: 
    682682        _sig_on
    683683        cdef int *tmp_array_out
    684684        cdef int *tmp_array_in
    685         cdef bool is_admissible
     685        cdef bint is_admissible
    686686
    687687        # as long as there is a non-void partial copy of H in G
    688688        while self.active >= 0:
  • sage/libs/flint/fmpz_poly.pyx

    diff --git a/sage/libs/flint/fmpz_poly.pyx b/sage/libs/flint/fmpz_poly.pyx
    a b cdef class Fmpz_poly(SageObject): 
    115115            8  0 0 0 0 0 0 0 1
    116116        """
    117117        cdef char* ss = fmpz_poly_to_string(self.poly)
    118         s = ss
     118        cdef object s = ss
    119119        free(ss)
    120120        return s
    121121       
  • sage/libs/pari/gen.pyx

    diff --git a/sage/libs/pari/gen.pyx b/sage/libs/pari/gen.pyx
    a b cdef class gen(sage.structure.element.Ri 
    13921392        if signe(x) < 0:
    13931393            sp = sp-1
    13941394            sp[0] = c'-'
    1395         k = sp
     1395        k = <object>sp
    13961396        sage_free(s)
    13971397        return k
    13981398       
    cdef class PariInstance(sage.structure.p 
    90639063        if PyObject_TypeCheck(s, gen):
    90649064            return s
    90659065        elif PyObject_TypeCheck(s, Integer):
    9066             return self.new_gen_from_mpz_t(<mpz_t>(<void *>s + mpz_t_offset))
     9066            return self.new_gen_from_mpz_t(<void *>s + mpz_t_offset)
    90679067        elif PyObject_HasAttrString(s, "_pari_"):
    90689068            return s._pari_()
    90699069        elif isinstance(s, (types.ListType, types.XRangeType,
  • sage/matrix/matrix_mod2_dense.pyx

    diff --git a/sage/matrix/matrix_mod2_dense.pyx b/sage/matrix/matrix_mod2_dense.pyx
    a b cdef class Matrix_mod2_dense(matrix_dens 
    463463        cdef list row_div, col_div
    464464        if self.subdivisions is not None:
    465465            row_s = empty_row
    466             div_s = row_divider = "[%s]" % ("-" * (self._ncols*2-1))
     466            div_s = row_divider = b"[%s]" % ("-" * (self._ncols*2-1))
    467467            row_div, col_div = self.get_subdivisions()
    468468            last_i = 0
    469469            for i in col_div:
    cdef class Matrix_mod2_dense(matrix_dens 
    475475                last_i = i
    476476           
    477477        for i from 0 <= i < self._nrows:
    478             row_s = row = "[%s]" % empty_row
     478            row_s = row = b"[%s]" % empty_row
    479479            for j from 0 <= j < self._ncols:
    480480                row_s[1+2*j] = c'0' + mzd_read_bit(self._entries,i,j)
    481481            s.append(row)
  • sage/misc/bitset.pxi

    diff --git a/sage/misc/bitset.pxi b/sage/misc/bitset.pxi
    a b cdef bitset_string(bitset_t bits): 
    669669    Return a python string representing the bitset.
    670670    """
    671671    cdef char* s = bitset_chars(NULL, bits)
     672    cdef object py_s
    672673    py_s = s
    673674    sage_free(s)
    674675    return py_s
  • sage/misc/sageinspect.py

    diff --git a/sage/misc/sageinspect.py b/sage/misc/sageinspect.py
    a b def __internal_tests(): 
    10551055        sage: sage_getdef(sage.rings.integer.Integer.factor, obj_name='factor')
    10561056        "factor(algorithm='pari', proof=True, limit=None)"
    10571057
    1058     A cython method without an embedded position can lead to surprising errors::
    1059    
    1060         sage: sage_getsource(sage.rings.integer.Integer.__init__, is_binary=True)
    1061         Traceback (most recent call last):
    1062         ...
    1063         TypeError: arg is not a module, class, method, function, traceback, frame, or code object
    1064 
    10651058        sage: sage_getdef(sage.rings.integer.Integer.__init__, obj_name='__init__')
    1066         '__init__( [noargspec] )'
    1067 
     1059        '__init__(x=None, base=0)'
     1060 
    10681061    Test _extract_source with some likely configurations, including no trailing
    10691062    newline at the end of the file::
    10701063   
  • sage/numerical/mip.pyx

    diff --git a/sage/numerical/mip.pyx b/sage/numerical/mip.pyx
    a b class LinearFunction: 
    17151715            5 x_2 +2 x_3
    17161716        """
    17171717        cdef dict d = deepcopy(self._f)
    1718         cdef bool first = True
     1718        cdef bint first = True
    17191719        t = ""
    17201720
    17211721        if d.has_key(-1):
  • sage/numerical/mip_glpk.pyx

    diff --git a/sage/numerical/mip_glpk.pyx b/sage/numerical/mip_glpk.pyx
    a b def write_lp(self, filename): 
    181181
    182182    glp_write_lp(lp,NULL,filename)
    183183
    184 cdef int build_glp_prob(c_glp_prob * lp, c_glp_iocp * iocp, LP, int log, bool names) except -1:
     184cdef int build_glp_prob(c_glp_prob * lp, c_glp_iocp * iocp, LP, int log, bint names) except -1:
    185185    """
    186186    Builds the GLPK structure corresponding to the LP
    187187
  • sage/numerical/osi_interface.pxd

    diff --git a/sage/numerical/osi_interface.pxd b/sage/numerical/osi_interface.pxd
    a b cdef extern from "../../local/include/co 
    1010     ctypedef struct c_CoinPackedMatrix "CoinPackedMatrix":
    1111         void setDimensions(int, int)
    1212         void appendRow(c_CoinPackedVector)
    13      c_CoinPackedMatrix *new_c_CoinPackedMatrix "new CoinPackedMatrix" (bool, double, double)
     13     c_CoinPackedMatrix *new_c_CoinPackedMatrix "new CoinPackedMatrix" (bint, double, double)
    1414     void del_CoinPackedMatrix "delete" (c_CoinPackedMatrix *)
    1515
    1616cdef extern from "../../local/include/coin/CoinMessageHandler.hpp":
    cdef extern from "../../local/include/co 
    8686     void del_OsiCbcSolverInterface "delete" (c_OsiCbcSolverInterface *)
    8787
    8888cdef class Osi_interface:
    89      cdef float osi_solve(self, LP, c_OsiSolverInterface * si,bool objective_only, bool is_cplex) except? -687654
     89     cdef float osi_solve(self, LP, c_OsiSolverInterface * si, bint objective_only, bint is_cplex) except? -687654
  • sage/numerical/osi_interface.pyx

    diff --git a/sage/numerical/osi_interface.pyx b/sage/numerical/osi_interface.pyx
    a b cdef int REAL = -1 
    66cdef int INTEGER = 0
    77
    88cdef class Osi_interface:
    9     cdef float osi_solve(self, LP, c_OsiSolverInterface * si,bool objective_only, bool is_cplex):
     9    cdef float osi_solve(self, LP, c_OsiSolverInterface * si, bint objective_only, bint is_cplex):
    1010        from itertools import izip
    1111        n_cols = len(LP._variables_type);
    1212   
  • sage/rings/complex_interval.pyx

    diff --git a/sage/rings/complex_interval.pyx b/sage/rings/complex_interval.pyx
    a b cdef class ComplexIntervalFieldElement(s 
    9595            R = parent._real_field()
    9696            rr = R(real)
    9797            ii = R(imag)
    98             mpfi_set(self.__re, <mpfi_t> rr.value)
    99             mpfi_set(self.__im, <mpfi_t> ii.value)
     98            mpfi_set(self.__re, rr.value)
     99            mpfi_set(self.__im, ii.value)
    100100        except TypeError:
    101101            raise TypeError, "unable to coerce to a ComplexIntervalFieldElement"
    102102
    cdef class ComplexIntervalFieldElement(s 
    246246            True
    247247        """
    248248        cdef ComplexIntervalFieldElement a00 = self._new()
    249         mpfr_set(<mpfr_t> &a00.__re.left, <mpfr_t> &self.__re.left, GMP_RNDN)
    250         mpfi_mid(<mpfr_t> &a00.__re.right, self.__re)
    251         mpfr_set(<mpfr_t> &a00.__im.left, <mpfr_t> &self.__im.left, GMP_RNDN)
    252         mpfi_mid(<mpfr_t> &a00.__im.right, self.__im)
     249        mpfr_set(&a00.__re.left, &self.__re.left, GMP_RNDN)
     250        mpfi_mid(&a00.__re.right, self.__re)
     251        mpfr_set(&a00.__im.left, &self.__im.left, GMP_RNDN)
     252        mpfi_mid(&a00.__im.right, self.__im)
    253253
    254254        cdef ComplexIntervalFieldElement a01 = self._new()
    255         mpfr_set(<mpfr_t> &a01.__re.left, <mpfr_t> &a00.__re.right, GMP_RNDN)
    256         mpfr_set(<mpfr_t> &a01.__re.right, <mpfr_t> &self.__re.right, GMP_RNDN)
     255        mpfr_set(&a01.__re.left, &a00.__re.right, GMP_RNDN)
     256        mpfr_set(&a01.__re.right, &self.__re.right, GMP_RNDN)
    257257        mpfi_set(a01.__im, a00.__im)
    258258       
    259259        cdef ComplexIntervalFieldElement a10 = self._new()
    260260        mpfi_set(a10.__re, a00.__re)
    261         mpfi_mid(<mpfr_t> &a10.__im.left, self.__im)
    262         mpfr_set(<mpfr_t> &a10.__im.right, <mpfr_t> &self.__im.right, GMP_RNDN)
     261        mpfi_mid(&a10.__im.left, self.__im)
     262        mpfr_set(&a10.__im.right, &self.__im.right, GMP_RNDN)
    263263       
    264264        cdef ComplexIntervalFieldElement a11 = self._new()
    265265        mpfi_set(a11.__re, a01.__re)
    cdef class ComplexIntervalFieldElement(s 
    469469        mpfi_sqr(t0, self.__re)
    470470        mpfi_sqr(t1, self.__im)
    471471
    472         mpfi_add(<mpfi_t> x.value, t0, t1)
     472        mpfi_add(x.value, t0, t1)
    473473       
    474474        mpfi_clear(t0)
    475475        mpfi_clear(t1)
    cdef class ComplexIntervalFieldElement(s 
    486486        mpfi_sqr(t0, self.__re)
    487487        mpfi_sqr(t1, self.__im)
    488488
    489         mpfi_add(<mpfi_t> x.value, t0, t1)
    490         mpfi_sqrt(<mpfi_t> x.value, <mpfi_t> x.value)
     489        mpfi_add(x.value, t0, t1)
     490        mpfi_sqrt(x.value, x.value)
    491491
    492492        mpfi_clear(t0)
    493493        mpfi_clear(t1)
  • sage/rings/complex_number.pyx

    diff --git a/sage/rings/complex_number.pyx b/sage/rings/complex_number.pyx
    a b cdef class ComplexNumber(sage.structure. 
    154154            R = parent._real_field()
    155155            rr = R(real)
    156156            ii = R(imag)
    157             mpfr_set(self.__re, <mpfr_t> rr.value, rnd)
    158             mpfr_set(self.__im, <mpfr_t> ii.value, rnd)
     157            mpfr_set(self.__re, rr.value, rnd)
     158            mpfr_set(self.__im, ii.value, rnd)
    159159        except TypeError:
    160160            raise TypeError, "unable to coerce to a ComplexNumber: %s" % type(real)
    161161
    cdef class ComplexNumber(sage.structure. 
    604604        mpfr_mul(t0, self.__re, self.__re, rnd)
    605605        mpfr_mul(t1, self.__im, self.__im, rnd)
    606606
    607         mpfr_add(<mpfr_t> x.value, t0, t1, rnd)
     607        mpfr_add(x.value, t0, t1, rnd)
    608608       
    609609        mpfr_clear(t0)
    610610        mpfr_clear(t1)
    cdef class ComplexNumber(sage.structure. 
    621621        mpfr_mul(t0, self.__re, self.__re, rnd)
    622622        mpfr_mul(t1, self.__im, self.__im, rnd)
    623623
    624         mpfr_add(<mpfr_t> x.value, t0, t1, rnd)
    625         mpfr_sqrt(<mpfr_t> x.value, <mpfr_t> x.value, rnd)
     624        mpfr_add(x.value, t0, t1, rnd)
     625        mpfr_sqrt(x.value, x.value, rnd)
    626626
    627627        mpfr_clear(t0)
    628628        mpfr_clear(t1)
    cdef class ComplexNumber(sage.structure. 
    772772        """
    773773        cdef real_mpfr.RealNumber x
    774774        x = real_mpfr.RealNumber(self._parent._real_field(), None)
    775         mpfr_set(<mpfr_t> x.value, self.__re, rnd)
     775        mpfr_set(x.value, self.__re, rnd)
    776776        return x
    777777
    778778    real_part = real
    cdef class ComplexNumber(sage.structure. 
    794794        """
    795795        cdef real_mpfr.RealNumber x
    796796        x = real_mpfr.RealNumber(self._parent._real_field(), None)
    797         mpfr_set(<mpfr_t> x.value, self.__im, rnd)
     797        mpfr_set(x.value, self.__im, rnd)
    798798        return x
    799799
    800800    imag_part = imag
    cdef class ComplexNumber(sage.structure. 
    963963            1.4142135623730951
    964964        """
    965965        if mpfr_zero_p(self.__im):
    966             return mpfr_get_d(<mpfr_t> self.__re, rnd)
     966            return mpfr_get_d(self.__re, rnd)
    967967        else:
    968968            raise TypeError, "Unable to convert %s to float; use abs() or real_part() as desired"%self
    969969       
    cdef class ComplexNumber(sage.structure. 
    17101710        """
    17111711        cdef real_mpfr.RealNumber x
    17121712        x = real_mpfr.RealNumber(self._parent._real_field(), None)
    1713         mpfr_atan2(<mpfr_t> x.value, self.__im, self.__re, rnd)
     1713        mpfr_atan2(x.value, self.__im, self.__re, rnd)
    17141714        return x
    17151715       
    17161716
    cdef class ComplexNumber(sage.structure. 
    20162016        rho = abs(self)
    20172017        arg = self.argument() / n
    20182018        mpfr_init2(r, self._prec)
    2019         mpfr_root(r, <mpfr_t> rho.value, n, rnd)
     2019        mpfr_root(r, rho.value, n, rnd)
    20202020
    2021         mpfr_sin_cos(z.__im, z.__re, <mpfr_t> arg.value, rnd)
     2021        mpfr_sin_cos(z.__im, z.__re, arg.value, rnd)
    20222022        mpfr_mul(z.__re, z.__re, r, rnd)
    20232023        mpfr_mul(z.__im, z.__im, r, rnd)
    20242024
    cdef class ComplexNumber(sage.structure. 
    20332033        for k in range(1, n):
    20342034            z = self._new()
    20352035            arg += theta
    2036             mpfr_sin_cos(z.__im, z.__re, <mpfr_t> arg.value, rnd)
     2036            mpfr_sin_cos(z.__im, z.__re, arg.value, rnd)
    20372037            mpfr_mul(z.__re, z.__re, r, rnd)
    20382038            mpfr_mul(z.__im, z.__im, r, rnd)
    20392039            zlist.append(z)
  • sage/rings/polynomial/multi_polynomial_libsingular.pyx

    diff --git a/sage/rings/polynomial/multi_polynomial_libsingular.pyx b/sage/rings/polynomial/multi_polynomial_libsingular.pyx
    a b cdef class MPolynomial_libsingular(sage. 
    27732773        _p = p_Head(self._poly, _ring)
    27742774        _n = p_GetCoeff(_p, _ring)
    27752775
    2776         ret = (not self._poly.next) and n_IsOne(_n, _ring)
     2776        ret = bool((not self._poly.next) and n_IsOne(_n, _ring))
    27772777
    27782778        p_Delete(&_p, _ring)
    27792779        return ret
  • sage/rings/polynomial/pbori.pyx

    diff --git a/sage/rings/polynomial/pbori.pyx b/sage/rings/polynomial/pbori.pyx
    a b cdef class GroebnerStrategy: 
    62026202        elif name is 'extended_product_criterions':
    62036203            return self._strat.extendedProductCriterions
    62046204        elif name is 'matrix_prefix':
    6205             _tmp =  <char *>self._strat.matrixPrefix.c_str()
    6206             return _tmp
     6205            return self._strat.matrixPrefix.c_str()
    62076206
    62086207        raise AttributeError, name
    62096208       
  • sage/rings/polynomial/real_roots.pxd

    diff --git a/sage/rings/polynomial/real_roots.pxd b/sage/rings/polynomial/real_roots.pxd
    a b  
    1 from rational import Rational
     1from sage.rings.rational import Rational
    22from sage.rings.rational cimport Rational
    33
    44from sage.modules.vector_integer_dense cimport Vector_integer_dense
    55
    66from sage.modules.vector_real_double_dense cimport Vector_real_double_dense
    77
    8 from real_mpfi import RealIntervalFieldElement
     8from sage.rings.real_mpfi import RealIntervalFieldElement
    99from sage.rings.real_mpfi cimport RealIntervalFieldElement
    1010
    1111cdef class interval_bernstein_polynomial:
  • sage/rings/real_mpfi.pyx

    diff --git a/sage/rings/real_mpfi.pyx b/sage/rings/real_mpfi.pyx
    a b cdef class RealIntervalFieldElement(sage 
    986986            mpfi_set(self.value, _x.value)
    987987        elif PY_TYPE_CHECK(x, RealNumber):
    988988            rn = x
    989             mpfi_set_fr(self.value, <mpfr_t> rn.value)
     989            mpfi_set_fr(self.value, rn.value)
    990990        elif PY_TYPE_CHECK(x, Rational):
    991991            rat = x
    992992            mpfi_set_q(self.value, <mpq_t> rat.value)
    cdef class RealIntervalFieldElement(sage 
    10041004            if PY_TYPE_CHECK(a, RealNumber) and PY_TYPE_CHECK(b, RealNumber):
    10051005                rn = a
    10061006                rn1 = b
    1007                 mpfi_interv_fr(self.value, <mpfr_t> rn.value, <mpfr_t> rn1.value)
     1007                mpfi_interv_fr(self.value, rn.value, rn1.value)
    10081008            elif PY_TYPE_CHECK(a, RealDoubleElement) and PY_TYPE_CHECK(b, RealDoubleElement):
    10091009                dx = a
    10101010                dx1 = b
    cdef class RealIntervalFieldElement(sage 
    10251025            else:  # generic fallback
    10261026                rn  = self._parent(a).lower()
    10271027                rn1 = self._parent(b).upper()
    1028                 mpfi_interv_fr(self.value, <mpfr_t> rn.value, <mpfr_t> rn1.value)
     1028                mpfi_interv_fr(self.value, rn.value, rn1.value)
    10291029               
    10301030        elif isinstance(x, sage.rings.qqbar.AlgebraicReal):
    10311031            d = x.interval(self._parent)
    cdef class RealIntervalFieldElement(sage 
    10501050                    rn1 = self._parent._upper_field()(x)
    10511051                except TypeError:
    10521052                    raise TypeError, "Unable to convert number to real interval."
    1053                 mpfi_interv_fr(self.value, <mpfr_t> rn.value, <mpfr_t> rn1.value)
     1053                mpfi_interv_fr(self.value, rn.value, rn1.value)
    10541054
    10551055    def __reduce__(self):
    10561056        """
    cdef class RealIntervalFieldElement(sage 
    19441944            x = (<RealIntervalField_class>self._parent).__lower_field._new()
    19451945        else:
    19461946            x = (<RealField_class>(self._parent._real_field(rnd)))._new()
    1947         mpfi_get_left(<mpfr_t> x.value, self.value)
     1947        mpfi_get_left(x.value, self.value)
    19481948        return x
    19491949
    19501950    def upper(self, rnd =None):
    cdef class RealIntervalFieldElement(sage 
    19941994            x = (<RealIntervalField_class>self._parent).__upper_field._new()
    19951995        else:
    19961996            x = ((<RealField_class>self._parent._real_field(rnd)))._new()
    1997         mpfi_get_right(<mpfr_t> x.value, self.value)
     1997        mpfi_get_right(x.value, self.value)
    19981998        return x
    19991999   
    20002000    def endpoints(self, rnd=None):
    cdef class RealIntervalFieldElement(sage 
    20302030        """
    20312031        cdef RealNumber x
    20322032        x = (<RealIntervalField_class>self._parent).__middle_field._new()
    2033         mpfi_diam_abs(<mpfr_t> x.value, self.value)
     2033        mpfi_diam_abs(x.value, self.value)
    20342034        return x
    20352035
    20362036    def relative_diameter(self):
    cdef class RealIntervalFieldElement(sage 
    20452045        """
    20462046        cdef RealNumber x
    20472047        x = (<RealIntervalField_class>self._parent).__middle_field._new()
    2048         mpfi_diam_rel(<mpfr_t> x.value, self.value)
     2048        mpfi_diam_rel(x.value, self.value)
    20492049        return x
    20502050
    20512051    def diameter(self):
    cdef class RealIntervalFieldElement(sage 
    20762076        """
    20772077        cdef RealNumber x
    20782078        x = (<RealIntervalField_class>self._parent).__middle_field._new()
    2079         mpfi_diam(<mpfr_t> x.value, self.value)
     2079        mpfi_diam(x.value, self.value)
    20802080        return x
    20812081
    20822082    def fp_rank_diameter(self):
    cdef class RealIntervalFieldElement(sage 
    21352135        """
    21362136        cdef RealNumber x
    21372137        x = (<RealIntervalField_class>self._parent).__middle_field._new()
    2138         mpfi_mag(<mpfr_t> x.value, self.value)
     2138        mpfi_mag(x.value, self.value)
    21392139        return x
    21402140
    21412141    def mignitude(self):
    cdef class RealIntervalFieldElement(sage 
    21532153        """
    21542154        cdef RealNumber x
    21552155        x = (<RealIntervalField_class>self._parent).__middle_field._new()
    2156         mpfi_mig(<mpfr_t> x.value, self.value)
     2156        mpfi_mig(x.value, self.value)
    21572157        return x
    21582158
    21592159    def center(self):
    cdef class RealIntervalFieldElement(sage 
    21672167        """
    21682168        cdef RealNumber x
    21692169        x = (<RealIntervalField_class>self._parent).__middle_field._new()
    2170         mpfi_mid(<mpfr_t> x.value, self.value)
     2170        mpfi_mid(x.value, self.value)
    21712171        return x
    21722172   
    21732173    def bisection(self):
    cdef class RealIntervalFieldElement(sage 
    21922192        """
    21932193        cdef RealIntervalFieldElement left = self._new()
    21942194        cdef RealIntervalFieldElement right = self._new()
    2195         mpfr_set(<mpfr_t> &left.value.left, <mpfr_t> &self.value.left, GMP_RNDN)   
    2196         mpfi_mid(<mpfr_t> &left.value.right, self.value)
    2197         mpfi_interv_fr(right.value, <mpfr_t> &left.value.right, <mpfr_t> &self.value.right)
     2195        mpfr_set(&left.value.left, &self.value.left, GMP_RNDN)   
     2196        mpfi_mid(&left.value.right, self.value)
     2197        mpfi_interv_fr(right.value, &left.value.right, &self.value.right)
    21982198        return left, right
    21992199
    22002200    def alea(self):
    cdef class RealIntervalFieldElement(sage 
    22092209        """
    22102210        cdef RealNumber x
    22112211        x = (<RealIntervalField_class>self._parent).__middle_field._new()
    2212         mpfi_alea(<mpfr_t> x.value, self.value)
     2212        mpfi_alea(x.value, self.value)
    22132213        return x
    22142214
    22152215#     def integer_part(self):
    cdef class RealIntervalFieldElement(sage 
    30863086            return mpfi_is_inside(other_intv.value, self.value)
    30873087        elif PY_TYPE_CHECK(other, RealNumber):
    30883088            other_rn = other
    3089             return mpfi_is_inside_fr(<mpfr_t> other_rn.value, self.value)
     3089            return mpfi_is_inside_fr(other_rn.value, self.value)
    30903090        try:
    30913091            other_intv = self._parent(other)
    30923092            return mpfi_is_inside(other_intv.value, self.value)
    cdef class RealIntervalFieldElement(sage 
    31913191        elif PY_TYPE_CHECK(other, RealNumber):
    31923192            other_rn = other
    31933193            mpfi_set(x.value, self.value)
    3194             mpfi_put_fr(x.value, <mpfr_t> other_rn.value)
     3194            mpfi_put_fr(x.value, other_rn.value)
    31953195        else:
    31963196            # Let type errors from _coerce_ propagate...
    31973197            other_intv = self._parent(other)
  • setup.py

    diff --git a/setup.py b/setup.py
    a b if not os.environ.has_key('SAGE_VERSION' 
    3838else:
    3939    SAGE_VERSION = os.environ['SAGE_VERSION']
    4040
     41try:
     42    compile_result_dir = os.environ['XML_RESULTS']
     43    keep_going = True
     44except KeyError:
     45    compile_result_dir = None
     46    keep_going = False
     47
    4148SITE_PACKAGES = '%s/lib/python/site-packages/'%SAGE_LOCAL
    4249if not os.path.exists(SITE_PACKAGES):
    4350    SITE_PACKAGES = '%s/lib/python2.5/site-packages/'%SAGE_LOCAL
    sage.ext.gen_interpreters.rebuild(SAGE_D 
    110117ext_modules = ext_modules + sage.ext.gen_interpreters.modules
    111118
    112119
     120#########################################################
     121### Testing related stuff
     122#########################################################
     123
     124
     125class CompileRecorder(object):
     126
     127    def __init__(self, f):
     128        self._f = f
     129        self._obj = None
     130   
     131    def __get__(self, obj, type=None):
     132        # Act like a method...
     133        self._obj = obj
     134        return self
     135
     136    def __call__(self, *args):
     137        t = time.time()
     138        try:
     139            if self._obj:
     140                res = self._f(self._obj, *args)
     141            else:
     142                res = self._f(*args)
     143        except Exception, ex:
     144            print ex
     145            res = ex
     146        t = time.time() - t
     147       
     148        errors = failures = 0
     149        if self._f is compile_command0:
     150            name = "cythonize." + args[0][1].name
     151            failures = int(bool(res))
     152        else:
     153            name = "gcc." + args[0][1].name
     154            errors = int(bool(res))
     155        if errors or failures:
     156            type = "failure" if failures else "error"
     157            failure_item = """<%(type)s/>""" % locals()
     158        else:
     159            failure_item = ""
     160        output = open("%s/%s.xml" % (compile_result_dir, name), "w")
     161        output.write("""
     162            <?xml version="1.0" ?>
     163            <testsuite name="%(name)s" errors="%(errors)s" failures="%(failures)s" tests="1" time="%(t)s">
     164            <testcase classname="%(name)s" name="compile">
     165            %(failure_item)s
     166            </testcase>
     167            </testsuite>
     168        """.strip() % locals())
     169        output.close()
     170        return res
     171
     172if compile_result_dir:
     173    record_compile = CompileRecorder
     174else:
     175    record_compile = lambda x: x
     176
     177
    113178######################################################################
    114179# CODE for generating C/C++ code from Cython and doing dependency
    115180# checking, etc.  In theory distutils would run Cython, but I don't
    ext_modules = ext_modules + sage.ext.gen 
    120185
    121186for m in ext_modules:
    122187    m.libraries = ['csage'] + m.libraries + ['stdc++', 'ntl']
    123     m.extra_compile_args += extra_compile_args
     188    m.extra_compile_args += extra_compile_args # + ["-DCYTHON_REFNANNY"]
    124189    if os.environ.has_key('SAGE_DEBIAN'):
    125190        m.library_dirs += ['/usr/lib','/usr/lib/eclib','/usr/lib/singular','/usr/lib/R/lib','%s/lib' % SAGE_LOCAL]
    126191    else:
    def execute_list_of_commands_in_serial(c 
    141206       
    142207    OUTPUT:
    143208        the given list of commands are all executed in serial
    144     """   
    145     for f,v in command_list:
    146         r = f(v)
    147         if r != 0:
    148             print "Error running command, failed with status %s."%r
    149             sys.exit(1)
     209    """
     210    process_command_results(f(v) for f,v in command_list)
    150211
    151212def run_command(cmd):
    152213    """
    def execute_list_of_commands_in_parallel 
    188249    from multiprocessing import Pool
    189250    import twisted.persisted.styles #doing this import will allow instancemethods to be pickable
    190251    p = Pool(nthreads)
    191     for r in p.imap(apply_pair, command_list):
     252    process_command_results(p.imap(apply_pair, command_list))
     253
     254def process_command_results(result_values):
     255    error = None
     256    for r in result_values:
    192257        if r:
    193             print "Parallel build failed with status %s."%r
    194             sys.exit(1)
     258            print "Error running command, failed with status %s."%r
     259            if not keep_going:
     260                sys.exit(1)
     261            error = r
     262    if error:
     263        sys.exit(1)
    195264
    196265def number_of_threads():
    197266    """
    class sage_build_ext(build_ext): 
    283352        # First, sanity-check the 'extensions' list
    284353        self.check_extensions_list(self.extensions)
    285354
    286         # We require MAKE to be set to decide how many cpus are
    287         # requested.
    288         if not os.environ.has_key('MAKE'):
    289             ncpus = 1
    290         else:
    291             MAKE = os.environ['MAKE']
    292             z = [w[2:] for w in MAKE.split() if w.startswith('-j')]
    293             if len(z) == 0:  # no command line option
    294                 ncpus = 1
    295             else:
    296                 # Determine number of cpus from command line argument.
    297                 # Also, use the OS to cap the number of cpus, in case
    298                 # user annoyingly makes a typo and asks to use 10000
    299                 # cpus at once.
    300                 try:
    301                     ncpus = int(z[0])
    302                     n = 2*number_of_threads()
    303                     if n:  # prevent dumb typos.
    304                         ncpus = min(ncpus, n)
    305                 except ValueError:
    306                     ncpus = 1
    307 
    308355        import time
    309356        t = time.time()
    310 
    311         if ncpus > 1:
    312 
    313             # First, decide *which* extensions need rebuilt at
    314             # all.
    315             extensions_to_compile = []
    316             for ext in self.extensions:
    317                 need_to_compile, p = self.prepare_extension(ext)
    318                 if need_to_compile:
    319                     extensions_to_compile.append(p)
    320 
    321             # If there were any extensions that needed to be
    322             # rebuilt, dispatch them using pyprocessing.
    323             if extensions_to_compile:
    324                from multiprocessing import Pool
    325                import twisted.persisted.styles #doing this import will allow instancemethods to be pickable
    326                p = Pool(min(ncpus, len(extensions_to_compile)))
    327                for r in p.imap(self.build_extension, extensions_to_compile):
    328                    pass
    329 
    330         else:
    331             for ext in self.extensions:
    332                 need_to_compile, p = self.prepare_extension(ext)
    333                 if need_to_compile:
    334                     self.build_extension(p)
     357       
     358        compile_commands = []
     359        for ext in self.extensions:
     360            need_to_compile, p = self.prepare_extension(ext)
     361            if need_to_compile:
     362                compile_commands.append((record_compile(self.build_extension), p))
     363       
     364        execute_list_of_commands(compile_commands)
    335365
    336366        print "Total time spent compiling C/C++ extensions: ", time.time() - t, "seconds."
    337367
    class sage_build_ext(build_ext): 
    464494###### Dependency checking
    465495#############################################
    466496
    467 CYTHON_INCLUDE_DIRS=[ SAGE_LOCAL + '/lib/python/site-packages/Cython/Includes/' ]
     497CYTHON_INCLUDE_DIRS=[
     498    SAGE_LOCAL + '/lib/python/site-packages/Cython/Includes/',
     499    SAGE_LOCAL + '/lib/python/site-packages/Cython/Includes/Deprecated/',
     500]
    468501
    469502# matches any dependency
    470503import re
    class DependencyTree: 
    574607                        deps.add(new_path)
    575608                        found_include = True
    576609                        break
     610                    new_path = os.path.normpath(idir + base_dependency_name[:-4] + "/__init__.pxd")
     611                    if os.path.exists(new_path):
     612                        deps.add(new_path)
     613                        found_include = True
     614                        break
    577615                # so we really couldn't find the dependency -- raise
    578616                # an exception.
    579617                if not found_include:
    def process_filename(f, m): 
    646684    else:
    647685        return f
    648686
    649 def compile_command(p):
     687def compile_command0(p):
    650688    """
    651689    Given a pair p = (f, m), with a .pyx file f which is a part the
    652690    module m, call Cython on f
    def compile_command(p): 
    669707            outfile += ".c"
    670708
    671709        # call cython, abort if it failed
    672         cmd = "python `which cython` --embed-positions --directive cdivision=True -I%s -o %s %s"%(os.getcwd(), outfile, f)
     710        cmd = "python `which cython` --embed-positions --directive cdivision=True,autotestdict=False -I%s -o %s %s"%(os.getcwd(), outfile, f)
    673711        r = run_command(cmd)
    674712        if r:
    675713            return r
    def compile_command(p): 
    697735   
    698736    return r
    699737
     738# Can't pickle decorated functions.
     739compile_command = record_compile(compile_command0)
     740
     741
    700742def compile_command_list(ext_modules, deps):
    701743    """
    702744    Computes a list of commands needed to compile and link the