Trac 16127: remove doctest
Arghs, again other code within same file. Corrected.
Trac #16127: Fix comparison of PARI objects

Comparison of PARI rationals is seriously broken:
{{{
sage: pari(1/2) < pari(1/3)
True
sage: pari(1) < pari(1/2)
True
}}}
Furthermore,the following PARI series and ''p''-adics are incorrectly
considered to be non-zero by `==` and `!=`:
{{{
sage: a = pari('O(x)'); a, a.type()
(O(x), 't_SER')
sage: b = pari('O(2)'); b, b.type()
(O(2), 't_PADIC')
sage: a.gequal(0)
True
sage: b.gequal(0)
True
sage: a == 0
False  # should be True
sage: b == 0
False  # should be True
}}}
These bugs are caused by `__cmp__()` calling the function `gcmp_sage()`
in `sage/libs/pari/misc.h` (custom replacement for PARI's `gcmp()`),
which uses string comparison for all types other than `t_INT` and
`t_REAL`.

A possible solution is to implement `gen._richcmp_c_impl()` and to fix
`gen._cmp_c_impl()` to use the standard PARI `gcmp()` instead of
`gcmp_sage()`.  This requires catching PARI "forbidden comparison"
errors.  There is actually a non-negligible speed-up if no such error
occurs, but a substantial penalty if an error does occur.

URL: http://trac.sagemath.org/16127
Reported by: pbruin
Ticket author(s): Peter Bruin
Reviewer(s): Jeroen Demeyer
Trac #17026: Compare PARI objects using cmp_universal() instead of strcmp()

After the separate implementations of `__cmp__()` and `__richcmp__()`
for PARI objects in #16127, it is a small step to replace the string
comparison in `__cmp__()` by the built-in PARI function
`cmp_universal()`.  This is faster, mathematically no more or less
meaningful, and (unlike string comparison) gives a total ordering on the
set of PARI objects up to the "indistinguishability" relation
(`gidentical()`).

An example of two elements that used to be indistinguishable to `cmp()`:
{{{
sage: a = pari("0*ffgen(ffinit(29, 10, 't))"); a
0
sage: b = pari(0); b
0
sage: cmp(a, b)
1
}}}

URL: http://trac.sagemath.org/17026
Reported by: pbruin
Ticket author(s): Peter Bruin
Reviewer(s): Jeroen Demeyer
Merge commit '8c93016' into isogs-ecnf
Merge branch 'public/combinat/crystals/tensor_construction-16001' of trac.sagemath.org:sage into public/combinat/crystals/tensor_construction-16001
Fixed failing doctests.
Fixing categories with tensor products.
#16743: fix doc output problem and turn on isogeny graph tests
trac #17042: Improvement to subsets_with_hereditary_property
Fixed docstrings and added test for matching Cartan types.
Trac #12295: maple interface broken

With sage-4.7 (and maple 14) it works:
{{{
----------------------------------------------------------------------
| Sage Version 4.7, Release Date: 2011-05-23                         |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
sage: maple('1+1')
2
sage:
}}}

But with 4.7.2 all maple commands end in this traceback:
{{{
----------------------------------------------------------------------
| Sage Version 4.7.2, Release Date: 2011-10-29                       |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
sage: maple('1+1')
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (17, 0))

------------------------------------------------------------------------
---
RuntimeError                              Traceback (most recent call
last)

/home/luther/<ipython console> in <module>()

/home/luther/sage-4.7.2-linux-64bit-ubuntu_10.04.3_lts-
x86_64-Linux/local/lib/python2.6/site-packages/IPython/Prompts.pyc in
__call__(self, arg)
    550
    551             # and now call a possibly user-defined print
mechanism
--> 552             manipulated_val = self.display(arg)
    553
    554             # user display hooks can change the variable to be
stored in

/home/luther/sage-4.7.2-linux-64bit-ubuntu_10.04.3_lts-
x86_64-Linux/local/lib/python2.6/site-packages/IPython/Prompts.pyc in
_display(self, arg)
    576             return IPython.generics.result_display(arg)
    577         except TryNext:
--> 578             return self.shell.hooks.result_display(arg)
    579
    580     # Assign the default display method:

/home/luther/sage-4.7.2-linux-64bit-ubuntu_10.04.3_lts-
x86_64-Linux/local/lib/python2.6/site-packages/IPython/hooks.pyc in
__call__(self, *args, **kw)
    139             #print "prio",prio,"cmd",cmd #dbg
    140             try:
--> 141                 ret = cmd(*args, **kw)
    142                 return ret
    143             except ipapi.TryNext, exc:

/home/luther/sage-4.7.2-linux-64bit-ubuntu_10.04.3_lts-
x86_64-Linux/local/lib/python2.6/site-packages/sage/misc/displayhook.pyc
in result_display(ip_self, obj)
    148     # IPython's default result_display() uses the
IPython.genutils.Term.cout stream.
    149     # See also local/lib/python2.6/site-
packages/IPython/hooks.py.
--> 150     print_obj(IPython.genutils.Term.cout, obj)
    151
    152 def displayhook(obj):

/home/luther/sage-4.7.2-linux-64bit-ubuntu_10.04.3_lts-
x86_64-Linux/local/lib/python2.6/site-packages/sage/misc/displayhook.pyc
in print_obj(out_stream, obj)
    140             if _check_tall_list_and_print(out_stream, obj):
    141                 return
--> 142     print >>out_stream, `obj`
    143
    144 def result_display(ip_self, obj):

/home/luther/sage-4.7.2-linux-64bit-ubuntu_10.04.3_lts-
x86_64-Linux/local/lib/python2.6/site-packages/sage/interfaces/maple.pyc
in __repr__(self)
   1056         """
   1057         self._check_valid()
-> 1058         return self.parent().get(self._name)
   1059
   1060     def _latex_(self):

/home/luther/sage-4.7.2-linux-64bit-ubuntu_10.04.3_lts-
x86_64-Linux/local/lib/python2.6/site-packages/sage/interfaces/maple.pyc
in get(self, var)
    609             '2'
    610         """
--> 611         s = self.eval('printf("%%q",%s)'%var)
    612         return s
    613

/home/luther/sage-4.7.2-linux-64bit-ubuntu_10.04.3_lts-
x86_64-Linux/local/lib/python2.6/site-
packages/sage/interfaces/expect.pyc in eval(self, code, strip,
synchronize, locals, allow_use_file, split_lines, **kwds)
   1034                 if (split_lines is "nofile" and allow_use_file
and
   1035                         self._eval_using_file_cutoff and
len(code) > self._eval_using_file_cutoff):
-> 1036                     return self._eval_line_using_file(code)
   1037                 elif split_lines:
   1038                     return '\n'.join([self._eval_line(L,
allow_use_file=allow_use_file, **kwds)

/home/luther/sage-4.7.2-linux-64bit-ubuntu_10.04.3_lts-
x86_64-Linux/local/lib/python2.6/site-
packages/sage/interfaces/expect.pyc in _eval_line_using_file(self, line)
    653             tmp_to_use = self._remote_tmpfile()
    654         try:
--> 655             s =
self._eval_line(self._read_in_file_command(tmp_to_use),
allow_use_file=False)
    656         except pexpect.EOF, msg:
    657             if self._quit_string() in line:

/home/luther/sage-4.7.2-linux-64bit-ubuntu_10.04.3_lts-
x86_64-Linux/local/lib/python2.6/site-packages/sage/interfaces/maple.pyc
in _eval_line(self, line, allow_use_file, wait_for_prompt)
    559                 e.expect('__sage__;')
    560                 e.expect(self._prompt)
--> 561                 raise RuntimeError, "An error occurred running a
Maple command:\nINPUT:\n%s\nOUTPUT:\n%s"%(line, z)
    562         return z
    563

RuntimeError: An error occurred running a Maple command:
INPUT:
read "/home/luther/.sage//temp/dirac/18306//interface//tmp18309";
OUTPUT:
on line 2, unexpected end of input
Error, while reading
`/home/luther/.sage//temp/dirac/18306//interface//tmp18309`
}}}

see also #2120, #11288

URL: http://trac.sagemath.org/12295
Reported by: sluther
Ticket author(s): J Miguel Farto
Reviewer(s): Frédéric Chapoton, Volker Braun
Trac #16001: Make the tensor functorial construction work for crystals

So we don't have to use `TensorProductOfCrystals` (or with #15882
`crystals.TensorProduct`).
{{{
sage: B = CrystalOfTableaux(['A',2], shape=[2,1])

sage: tensor([B, B])
Full tensor product of the crystals
 [The crystal of tableaux of type ['A', 2] and shape(s) [[2, 1]],
  The crystal of tableaux of type ['A', 2] and shape(s) [[2, 1]]]

sage: B.tensor(B)
Full tensor product of the crystals
 [The crystal of tableaux of type ['A', 2] and shape(s) [[2, 1]],
  The crystal of tableaux of type ['A', 2] and shape(s) [[2, 1]]]
}}}

URL: http://trac.sagemath.org/16001
Reported by: tscrim
Ticket author(s): Travis Scrimshaw
Reviewer(s): Ben Salisbury, Anne Schilling
Trac #16961: Fix Dynatomic Polynomials to work over the Complex Numbers

{{{
P.<x,y> = ProjectiveSpace(CC, 1)
H = Hom(P,P)
f = H([x^2+(1+CC.0)*y^2,y^2])
f.dynatomic_polynomial(2)
}}}
returns the wrong answer

URL: http://trac.sagemath.org/16961
Reported by: jdefaria
Ticket author(s): Joao de Faria
Reviewer(s): Ben Hutz
Trac #13612: padic elements can not be initialized from residue field

In some cases a padic element can not be initialized from the zero of
the residue field.

{{{
sage: K=Qp(3)
sage: R.<a> = K[]
sage: L.<a> = K.extension(a^2+1)
sage: L(L.residue_field().one())
1 + O(3)
sage: L(L.residue_field().zero())
TypeError: cannot convert x to a p-adic element
}}}

The attached patch fixes this issue.

URL: http://trac.sagemath.org/13612
Reported by: saraedum
Ticket author(s): Julian Rueth
Reviewer(s): Volker Braun
Trac #13644: Error when creating ideal from unhashable elements

Currently, the following does not work because some padic extension
elements do not define a hash function (see #11895 for why they do not
define a hash function):
{{{
sage: K = Qp(3)
sage: R.<a> = K[]
sage: L.<a> = K.extension(a^2-3)
sage: L.ideal(a)
TypeError: unhashable type:
'sage.rings.padics.padic_ZZ_pX_CR_element.pAdicZZpXCRElement'
}}}

The problem is that {{{sage.rings.ring.Ring}}} is looking for a coercion
from {{{a}}} to {{{L}}}. There is none, since {{{a}}} is not a parent.
The attached patch fixes this.

URL: http://trac.sagemath.org/13644
Reported by: saraedum
Ticket author(s): Julian Rueth
Reviewer(s): Volker Braun
trac #17043 correct call to scilab as required by wstein
trac #17044 fix to pexpect interface, as required by wstein
Added check: direction must be 'up' or 'down'.
trac #17042: Bad code. Bad code everywhere.