Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

37395: Adjust doctests of Mathics interface to current version #45

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 11 additions & 21 deletions src/sage/interfaces/mathics.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@
::

sage: mathics('10.^80') # optional - mathics
1.*^80
1.×10^80
sage: mathics('10.^80').sage() # optional - mathics
1.00000000000000e80

Expand Down Expand Up @@ -483,6 +483,7 @@ def __init__(self,
self._seed = seed
self._initialized = False # done lazily
self._session = None
os.environ['MATHICS_CHARACTER_ENCODING'] = 'ASCII' # see :issue:`37395`

def _lazy_init(self):
r"""
Expand Down Expand Up @@ -603,7 +604,7 @@ def get(self, var):

sage: mathics.set('u', '2*x +E') # optional - mathics
sage: mathics.get('u') # optional - mathics
'E + 2 x'
'2 x + E'
"""
return self.eval(var)

Expand Down Expand Up @@ -719,9 +720,9 @@ def _exponent_symbol(self):

sage: bignum = mathics('10.^80') # optional - mathics
sage: repr(bignum) # optional - mathics
'1.*^80'
'1.×10^80'
sage: repr(bignum).replace(mathics._exponent_symbol(), 'e').strip() # optional - mathics
'1.e80'
'1.×10^80'
"""
return '*^'

Expand Down Expand Up @@ -774,34 +775,25 @@ def help(self, cmd, long=False):
EXAMPLES::

sage: mathics.help('Sin') # optional - mathics
"\n 'Sin[z]'\n returns the sine of z.\n"
'sine function\n'

sage: print(_) # optional - mathics
<BLANKLINE>
'Sin[z]'
returns the sine of z.
sine function
<BLANKLINE>

sage: print(mathics.help('Sin', long=True)) # optional - mathics
<BLANKLINE>
'Sin[z]'
returns the sine of z.
sine function
<BLANKLINE>
Attributes[Sin] = {Listable, NumericFunction, Protected}
<BLANKLINE>

sage: print(mathics.Factorial.__doc__) # optional - mathics
<BLANKLINE>
'Factorial[n]'
'n!'
computes the factorial of n.
factorial
<BLANKLINE>

sage: u = mathics('Pi') # optional - mathics
sage: print(u.Cos.__doc__) # optional - mathics
<BLANKLINE>
'Cos[z]'
returns the cosine of z.
cosine function
<BLANKLINE>
"""
if long:
Expand Down Expand Up @@ -854,7 +846,7 @@ class MathicsElement(ExtraTabCompletion, InterfaceElement):
sage: expr = res.last_eval; expr
<Symbol: System`E>
sage: type(expr)
<class 'mathics.core.expression.Symbol'>
<class 'mathics.core.symbols.Symbol'>

Applying Mathics methods::

Expand All @@ -865,8 +857,6 @@ class MathicsElement(ExtraTabCompletion, InterfaceElement):
'System`E'
sage: me.is_inexact()
False
sage: me.is_symbol()
True

Conversion to Sage::

Expand Down