Ticket #9880: trac_9880-fix_comparison-p1.patch

File trac_9880-fix_comparison-p1.patch, 4.2 KB (added by jpflori, 10 years ago)
  • sage/libs/ginac/decl.pxi

    # HG changeset patch
    # User Volker Braun <vbraun@stp.dias.ie>
    # Date 1308337530 25200
    # Node ID aeee12819398d5fa36e96a114425c1f89a43aa29
    # Parent  0fc2ee37792419305be97899f4b4cbc8adda9b72
    Trac #9880: Fix for the x._cmp_add(1) crash.
    
    diff -r 0fc2ee377924 -r aeee12819398 sage/libs/ginac/decl.pxi
    a b  
    524524cdef extern from "pynac/order.h":
    525525    bint print_order_compare "GiNaC::print_order().compare" \
    526526            (GEx left, GEx right) except +
     527    bint print_order_compare_mul "GiNaC::print_order_mul().compare" \
     528            (GEx left, GEx right) except +
    527529    bint print_order "GiNaC::print_order()" \
    528530            (GEx left, GEx right) except +
    529531    bint print_order_mul "GiNaC::print_order_mul()" \
  • sage/symbolic/expression.pxd

    diff -r 0fc2ee377924 -r aeee12819398 sage/symbolic/expression.pxd
    a b  
    1212    cpdef bint is_infinity(self)
    1313    cpdef object pyobject(self)
    1414    cpdef Expression _subs_expr(self, expr)
    15     cpdef int _cmp_add(left, CommutativeRingElement right) except -2
    16     cpdef int _cmp_mul(left, CommutativeRingElement right) except -2
     15    cpdef int _cmp_add(Expression left, Expression right) except -2
     16    cpdef int _cmp_mul(Expression left, Expression right) except -2
    1717   
    1818cdef Expression new_Expression_from_GEx(parent, GEx juice)
    1919cdef Expression new_Expression_from_pyobject(parent, x)
  • sage/symbolic/expression.pyx

    diff -r 0fc2ee377924 -r aeee12819398 sage/symbolic/expression.pyx
    a b  
    26052605        return (<Element>left)._cmp(right)
    26062606
    26072607    cdef int _cmp_c_impl(left, Element right) except -2:
    2608         return -print_order_compare((<Expression>right)._gobj,left._gobj)
    2609 
    2610     cpdef int _cmp_add(left, CommutativeRingElement right) except -2:
    2611         return print_order(left._gobj,(<Expression>right)._gobj)
    2612 
    2613     cpdef int _cmp_mul(left, CommutativeRingElement right) except -2:
    2614         return print_order_mul(left._gobj,(<Expression>right)._gobj)
     2608        """
     2609        Compare ``left`` and ``right``.
     2610
     2611        INPUT:
     2612
     2613        - ``right`` -- A :class:`Expression` instance.
     2614
     2615        OUTPUT:
     2616
     2617        Boolean.
     2618
     2619        EXAMPLES::
     2620
     2621            sage: a = sqrt(3)
     2622            sage: b = x^2+1
     2623            sage: a.__cmp__(b)   # indirect doctest
     2624            -1
     2625        """
     2626        return print_order_compare(left._gobj, (<Expression>right)._gobj)
     2627
     2628    cpdef int _cmp_add(Expression left, Expression right) except -2:
     2629        """
     2630        Compare ``left`` and ``right`` in the print order.
     2631
     2632        INPUT:
     2633
     2634        - ``right`` -- A :class:`Expression` instance.
     2635
     2636        OUTPUT:
     2637
     2638        Boolean.
     2639
     2640        EXAMPLES::
     2641
     2642            sage: a = sqrt(3)
     2643            sage: b = x^2+1
     2644            sage: a._cmp_add(b)
     2645            -1
     2646            sage: b._cmp_add(a)
     2647            1
     2648            sage: b._cmp_add(1)
     2649            Traceback (most recent call last):
     2650            ...
     2651            TypeError: Argument 'right' has incorrect type (expected
     2652            sage.symbolic.expression.Expression, got sage.rings.integer.Integer)
     2653        """
     2654        return print_order_compare(left._gobj, right._gobj)
     2655
     2656    cpdef int _cmp_mul(Expression left, Expression right) except -2:
     2657        """
     2658        Compare ``left`` and ``right`` in the print order for products.
     2659
     2660        INPUT:
     2661
     2662        - ``right`` -- A :class:`Expression` instance.
     2663
     2664        OUTPUT:
     2665
     2666        Boolean.
     2667
     2668        EXAMPLES::
     2669
     2670            sage: a = sqrt(3)
     2671            sage: b = x^2+1
     2672            sage: a._cmp_mul(b)
     2673            -1
     2674            sage: b._cmp_mul(a)
     2675            1
     2676            sage: b._cmp_mul(1)
     2677            Traceback (most recent call last):
     2678            ...
     2679            TypeError: Argument 'right' has incorrect type (expected
     2680            sage.symbolic.expression.Expression, got sage.rings.integer.Integer)
     2681        """
     2682        return print_order_compare_mul(left._gobj, right._gobj)
    26152683
    26162684    def __pow__(self, exp, ignored):
    26172685        """