# HG changeset patch
# User Jean-Pierre Flori <flori@enst.fr>
# Date 1298990841 -3600
# Node ID 859858d8d29ba03198f011c7a95202128ca582d3
# Parent 98b80ddf6c9f18409d222bcb01622aa32ef8d18f
Trac #9880: Give Sage access to the PyNaC printing order
This allows automated doctests to check the PyNaC printing
sort order.
diff --git a/c_lib/include/ginac_wrap.h b/c_lib/include/ginac_wrap.h
a
|
b
|
|
143 | 143 | extern const ex _ex1_2; |
144 | 144 | |
145 | 145 | } |
| 146 | |
| 147 | #include <pynac/order.h> |
| 148 | |
| 149 | int cmp_add(const ex& lh, const ex& rh) { |
| 150 | return ex_is_greater_degrevlex::in_type(&add::tinfo_static).compare(lh,rh); |
| 151 | } |
| 152 | |
| 153 | int cmp_mul(const ex& lh, const ex& rh) { |
| 154 | return ex_is_greater_degrevlex::in_type(&mul::tinfo_static).compare(lh,rh); |
| 155 | } |
diff --git a/sage/libs/ginac/decl.pxi b/sage/libs/ginac/decl.pxi
a
|
b
|
|
507 | 507 | object (*py_rational_power_parts)(object basis, object exp) |
508 | 508 | |
509 | 509 | py_funcs_struct py_funcs "GiNaC::py_funcs" |
| 510 | |
| 511 | int cmp_add(GEx left, GEx right) except + |
| 512 | int cmp_mul(GEx left, GEx right) except + |
diff --git a/sage/symbolic/expression.pxd b/sage/symbolic/expression.pxd
a
|
b
|
|
1 | 1 | include "../libs/ginac/decl.pxi" |
2 | 2 | |
3 | | from sage.structure.element cimport CommutativeRingElement |
4 | | |
| 3 | from sage.structure.element cimport CommutativeRingElement, Element |
5 | 4 | |
6 | 5 | cdef class Expression(CommutativeRingElement): |
7 | 6 | cdef GEx _gobj |
… |
… |
|
12 | 11 | cpdef bint is_relational(self) |
13 | 12 | cpdef object pyobject(self) |
14 | 13 | cpdef Expression _subs_expr(self, expr) |
| 14 | cpdef int _cmp_add(left, Element right) except -2 |
| 15 | cpdef int _cmp_mul(left, Element right) except -2 |
15 | 16 | |
16 | 17 | cdef Expression new_Expression_from_GEx(parent, GEx juice) |
17 | 18 | cdef Expression new_Expression_from_pyobject(parent, x) |
| 19 | |
diff --git a/sage/symbolic/expression.pyx b/sage/symbolic/expression.pyx
a
|
b
|
|
2501 | 2501 | cdef int _cmp_c_impl(left, Element right) except -2: |
2502 | 2502 | return left._gobj.compare((<Expression>right)._gobj) |
2503 | 2503 | |
| 2504 | cpdef int _cmp_add(left, Element right) except -2: |
| 2505 | return cmp_add(left._gobj,(<Expression>right)._gobj) |
| 2506 | |
| 2507 | cpdef int _cmp_mul(left, Element right) except -2: |
| 2508 | return cmp_mul(left._gobj,(<Expression>right)._gobj) |
| 2509 | |
2504 | 2510 | def __pow__(self, exp, ignored): |
2505 | 2511 | """ |
2506 | 2512 | Return self raised to the power of exp. |