Simplify numerical evaluation of BuiltinFunctions
Merge remote-tracking branches 'origin/u/jdemeyer/ticket/17131' and 'origin/u/jdemeyer/ticket/17133' into ticket/17130
The "impossible" factorization is too easy
#17381 : remove $SAGE_ROOT/build/pkgs/mercurial directory
remove two references to mercurial, thanks to aapitzsch comment.
Merge branch 'u/jdemeyer/ticket/17130' of trac.sagemath.org:sage into 6.5beta1

* 'u/jdemeyer/ticket/17130' of trac.sagemath.org:sage:
  Simplify numerical evaluation of BuiltinFunctions

Conflicts:
	src/sage/functions/other.py
17130: reviewer's patch: fix typo
Fix Trac #17328 again in a better way
Call the factorial() method of an Integer
Trac #17410: unambiguously doctest longest_path()
Trac #17410: unambiguously doctest longest_path()

This version tests the equality of sets of edges.
Trac #17410: unambiguously doctest longest_path()

Cosmetics up to reviewer's suggestions
Fix numerical noise
Trac 17415: fix random failure in ell_rational_field.py
Trac #17130: Fix coercion bugs in symbolic functions

This uses coercion correctly:
{{{
sage: bessel_Y._eval_(RealField(300)(1), 1.0)
-0.781212821300289
}}}

However, it seems that `__call__()` coerces this result back to the
first parent, giving false precision:
{{{
sage: bessel_Y(RealField(300)(1), 1.0)
-0.781212821300288684511770043172873556613922119140625000000000000000000
000000000000000000000
}}}

Same issue with functions which are evaluated using Maxima, which does
not support arbitrary precision:
{{{
sage: R=RealField(300); elliptic_eu(R(1/2), R(1/8))
0.4950737320232014848642165816272608935832977294921875000000000000000000
00000000000000000000
}}}

The `gamma_inc()` function also mishandles parents:
{{{
sage: gamma_inc(float(0), float(1))
AttributeError: type object 'float' has no attribute 'precision'
}}}

----

Apart from this, this branch also removes lots of boilerplate from
`_eval_` like
{{{
if not isinstance(x, Expression) and not isinstance(y, Expression) and \
        (is_inexact(x) or is_inexact(y)):
    x, y = coercion_model.canonical_coercion(x, y)
    return self._evalf_(x, y, s_parent(x))
}}}
by wrapping `_eval_` inside the new method `_evalf_or_eval_` which
automatically does this boilerplate.

----

Possible follow-ups: #10133, #14766, #16587, #17122, #15200

URL: http://trac.sagemath.org/17130
Reported by: jdemeyer
Ticket author(s): Jeroen Demeyer
Reviewer(s): Ralf Stephan
Trac #17355: Random failure in qsieve

{{{
sage -t --long src/sage/interfaces/qsieve.py
**********************************************************************
File "src/sage/interfaces/qsieve.py", line 260, in
sage.interfaces.qsieve.qsieve_nonblock.quit
Failed example:
    qs.quit()
Exception raised:
    Traceback (most recent call last):
      File "/mnt/disk/home/buildslave-
sage/slave/sage_git/build/local/lib/python2.7/site-
packages/sage/doctest/forker.py", line 488, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/mnt/disk/home/buildslave-
sage/slave/sage_git/build/local/lib/python2.7/site-
packages/sage/doctest/forker.py", line 851, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.interfaces.qsieve.qsieve_nonblock.quit[3]>",
line 1, in <module>
        qs.quit()
      File "/mnt/disk/home/buildslave-
sage/slave/sage_git/build/local/lib/python2.7/site-
packages/sage/interfaces/qsieve.py", line 265, in quit
        os.killpg(int(pid),9)
    OSError: [Errno 3] No such process
**********************************************************************
File "src/sage/interfaces/qsieve.py", line 261, in
sage.interfaces.qsieve.qsieve_nonblock.quit
Failed example:
    qs
Expected:
    Factorization was terminated early.
Got:
    Proper factors so far: []
**********************************************************************
}}}

URL: http://trac.sagemath.org/17355
Reported by: vbraun
Ticket author(s): Volker Braun
Reviewer(s): Frédéric Chapoton
Trac #17415: Random failure in ell_rational_field.py

Garbage collection coming at the wrong time can cause
{{{
File "src/sage/schemes/elliptic_curves/ell_rational_field.py", line 590,
in sage.schemes.elliptic_curves.ell_rational_field.EllipticCurve_rationa
l_field.pari_curve
Failed example:
    _ = E.__dict__.pop('_pari_curve')  # clear cached data
Exception raised:
    Traceback (most recent call last):
      File "/usr/local/src/sage-config/local/lib/python2.7/site-
packages/sage/doctest/forker.py", line 488, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/usr/local/src/sage-config/local/lib/python2.7/site-
packages/sage/doctest/forker.py", line 851, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.schemes.elliptic_curves.ell_rational_field.Ell
ipticCurve_rational_field.pari_curve[9]>", line 1, in <module>
        _ = E.__dict__.pop('_pari_curve')  # clear cached data
    KeyError: '_pari_curve'
}}}

URL: http://trac.sagemath.org/17415
Reported by: jdemeyer
Ticket author(s): Peter Bruin
Reviewer(s): Volker Braun
Trac #17410: unambiguously doctest longest_path()

A doctest or longest_path() is ambiguous :
{{{
sage: l = [(0, 1), (0, 3), (2, 0)]
sage: G = DiGraph(l)
sage: G.longest_path().edges()
[(0, 3, None), (2, 0, None)]
}}}

Starting with sage 6.5beta1, sage gives the equally valid answer
{{{
[(0, 1, None), (2, 0, None)]
}}}
but this is detected as a failure by sage ptestlong.

So let's use a problem with a unique solution.

URL: http://trac.sagemath.org/17410
Reported by: charpent
Ticket author(s): Emmanuel Charpentier
Reviewer(s): Vincent Delecroix
Trac #17381: Remove outdated and currently unused mercurial package

Our Version of mercurial is 2.2.2 (more than 2 years old) while upstream
is at 3.2.1. We are not using it in our workflow for a while and it is
unlikely we will use it soon.

The aim of this ticket is to get rid of this package.

URL: http://trac.sagemath.org/17381
Reported by: tmonteil
Ticket author(s): Thierry Monteil
Reviewer(s): Frédéric Chapoton, André Apitzsch