Repository: sympy/sympy

Issue:
'Rational[m,n]' conversion from Mathematica fails to create a Rational
Minimal working example:

```
> from sympy.parsing.mathematica import parse_mathematica
> parse_mathematica("Rational[1,2]")
Rational(1, 2)
> parse_mathematica("Rational[1,2]") + 2
AttributeError: 'Rational' object has no attribute 'p'
```

I have investigated this a little, and the parser is creating an `AppliedUndef` function called `Rational` which appears to be a Rational as expected, but in fact fails to have any of the required attributes for a type named 'Rational' (in the MWE, it has no numerator attribute), leading to some strange and confusing behaviour.

The fix is to define the map from Mathematica's `Rational` to Sympy's `Rational`. I have a patch which seems to work, which I will submit as a PR shortly.

Discussion:

Patch:
diff --git a/.mailmap b/.mailmap
index 99e41da3b5..fa4f81a437 100644
--- a/.mailmap
+++ b/.mailmap
@@ -706,6 +706,7 @@ James Goppert <james.goppert@gmail.com>
 James Harrop <ebc121@gmail.com>
 James Pearson <xiong.chiamiov@gmail.com>
 James Taylor <user234683@tutanota.com>
+James Whitehead <whiteheadj@gmail.com> jcwhitehead <whiteheadj@gmail.com>
 Jan Kruse <janckruse@t-online.de>
 Jan-Philipp Hoffmann <sonntagsgesicht@icloud.com> Jan-Philipp Hoffmann <90828785+jan-philipp-hoffmann@users.noreply.github.com>
 Jared Lumpe <mjlumpe@gmail.com> Michael Jared Lumpe <mjlumpe@gmail.com>
diff --git a/sympy/parsing/mathematica.py b/sympy/parsing/mathematica.py
index d0cbe7f7b1..3856e0a411 100644
--- a/sympy/parsing/mathematica.py
+++ b/sympy/parsing/mathematica.py
@@ -5,7 +5,7 @@
 from typing import Any, Callable
 
 import sympy
-from sympy import Mul, Add, Pow, log, exp, sqrt, cos, sin, tan, asin, acos, acot, asec, acsc, sinh, cosh, tanh, asinh, \
+from sympy import Mul, Add, Pow, Rational, log, exp, sqrt, cos, sin, tan, asin, acos, acot, asec, acsc, sinh, cosh, tanh, asinh, \
     acosh, atanh, acoth, asech, acsch, expand, im, flatten, polylog, cancel, expand_trig, sign, simplify, \
     UnevaluatedExpr, S, atan, atan2, Mod, Max, Min, rf, Ei, Si, Ci, airyai, airyaiprime, airybi, primepi, prime, \
     isprime, cot, sec, csc, csch, sech, coth, Function, I, pi, Tuple, GreaterThan, StrictGreaterThan, StrictLessThan, \
@@ -131,6 +131,7 @@ class MathematicaParser:
     # left: Mathematica, right: SymPy
     CORRESPONDENCES = {
         'Sqrt[x]': 'sqrt(x)',
+        'Rational[x,y]': 'Rational(x,y)',
         'Exp[x]': 'exp(x)',
         'Log[x]': 'log(x)',
         'Log[x,y]': 'log(y,x)',
@@ -975,6 +976,7 @@ def converter(expr):
         "Times": Mul,
         "Plus": Add,
         "Power": Pow,
+        "Rational": Rational,
         "Log": lambda *a: log(*reversed(a)),
         "Log2": lambda x: log(x, 2),
         "Log10": lambda x: log(x, 10),


Test patch:
diff --git a/sympy/parsing/tests/test_mathematica.py b/sympy/parsing/tests/test_mathematica.py
index b6df911f30..c72b3e5eea 100644
--- a/sympy/parsing/tests/test_mathematica.py
+++ b/sympy/parsing/tests/test_mathematica.py
@@ -67,7 +67,8 @@ def test_mathematica():
         'LogIntegral[4]': ' li(4)',
         'PrimePi[7]': 'primepi(7)',
         'Prime[5]': 'prime(5)',
-        'PrimeQ[5]': 'isprime(5)'
+        'PrimeQ[5]': 'isprime(5)',
+        'Rational[2,19]': 'Rational(2,19)',    # test case for issue 25716
         }
 
     for e in d: