passagemath-standard-no-symbolics 10.6.31rc3__cp314-cp314-macosx_13_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of passagemath-standard-no-symbolics might be problematic. Click here for more details.

Files changed (82) hide show
  1. passagemath_standard_no_symbolics-10.6.31rc3.data/scripts/sage-grep +5 -0
  2. passagemath_standard_no_symbolics-10.6.31rc3.data/scripts/sage-grepdoc +5 -0
  3. passagemath_standard_no_symbolics-10.6.31rc3.data/scripts/sage-list-packages +103 -0
  4. passagemath_standard_no_symbolics-10.6.31rc3.dist-info/METADATA +151 -0
  5. passagemath_standard_no_symbolics-10.6.31rc3.dist-info/RECORD +82 -0
  6. passagemath_standard_no_symbolics-10.6.31rc3.dist-info/WHEEL +6 -0
  7. passagemath_standard_no_symbolics-10.6.31rc3.dist-info/top_level.txt +1 -0
  8. sage/all.py +207 -0
  9. sage/all_cmdline.py +36 -0
  10. sage/cli/__init__.py +61 -0
  11. sage/cli/__main__.py +5 -0
  12. sage/cli/eval_cmd.py +45 -0
  13. sage/cli/eval_cmd_test.py +25 -0
  14. sage/cli/interactive_shell_cmd.py +28 -0
  15. sage/cli/notebook_cmd.py +51 -0
  16. sage/cli/notebook_cmd_test.py +39 -0
  17. sage/cli/options.py +26 -0
  18. sage/cli/run_file_cmd.py +50 -0
  19. sage/cli/version_cmd.py +26 -0
  20. sage/databases/all.py +83 -0
  21. sage/databases/cubic_hecke_db.py +1527 -0
  22. sage/dynamics/all.py +31 -0
  23. sage/dynamics/surface_dynamics_deprecation.py +32 -0
  24. sage/ext_data/kenzo/CP2.txt +45 -0
  25. sage/ext_data/kenzo/CP3.txt +349 -0
  26. sage/ext_data/kenzo/CP4.txt +4774 -0
  27. sage/ext_data/kenzo/README.txt +49 -0
  28. sage/ext_data/kenzo/S4.txt +20 -0
  29. sage/ext_data/mwrank/PRIMES +1 -0
  30. sage/ext_data/nbconvert/postprocess.py +48 -0
  31. sage/ext_data/nbconvert/rst_sage.tpl +99 -0
  32. sage/ext_data/nodoctest +0 -0
  33. sage/ext_data/notebook-ipython/kernel.json.in +11 -0
  34. sage/ext_data/notebook-ipython/logo-64x64.png +0 -0
  35. sage/ext_data/notebook-ipython/logo.svg +352 -0
  36. sage/ext_data/valgrind/pyalloc.supp +58 -0
  37. sage/ext_data/valgrind/sage-additional.supp +417 -0
  38. sage/ext_data/valgrind/sage.supp +43 -0
  39. sage/ext_data/valgrind/valgrind-python.supp +480 -0
  40. sage/geometry/all.py +12 -0
  41. sage/groups/matrix_gps/pickling_overrides.py +110 -0
  42. sage/homology/tests.py +66 -0
  43. sage/interacts/algebra.py +20 -0
  44. sage/interacts/all.py +25 -0
  45. sage/interacts/calculus.py +24 -0
  46. sage/interacts/fractals.py +18 -0
  47. sage/interacts/geometry.py +19 -0
  48. sage/interacts/library.py +1950 -0
  49. sage/interacts/library_cython.cpython-314-darwin.so +0 -0
  50. sage/interacts/statistics.py +19 -0
  51. sage/interfaces/axiom.py +1002 -0
  52. sage/interfaces/kash.py +834 -0
  53. sage/interfaces/lie.py +950 -0
  54. sage/interfaces/matlab.py +413 -0
  55. sage/interfaces/mupad.py +686 -0
  56. sage/interfaces/octave.py +858 -0
  57. sage/interfaces/phc.py +943 -0
  58. sage/interfaces/psage.py +189 -0
  59. sage/interfaces/qsieve.py +4 -0
  60. sage/interfaces/r.py +2096 -0
  61. sage/interfaces/read_data.py +46 -0
  62. sage/interfaces/scilab.py +576 -0
  63. sage/interfaces/tests.py +81 -0
  64. sage/libs/all.py +11 -0
  65. sage/libs/cremona/__init__.py +0 -0
  66. sage/libs/mwrank/__init__.py +0 -0
  67. sage/logic/all.py +3 -0
  68. sage/logic/booleval.py +160 -0
  69. sage/logic/boolformula.py +1490 -0
  70. sage/logic/logic.py +856 -0
  71. sage/logic/logicparser.py +696 -0
  72. sage/logic/logictable.py +272 -0
  73. sage/logic/propcalc.py +311 -0
  74. sage/misc/all.py +28 -0
  75. sage/misc/lazy_attribute.pyi +11 -0
  76. sage/rings/all.py +48 -0
  77. sage/rings/commutative_algebra.py +38 -0
  78. sage/rings/finite_rings/all.py +21 -0
  79. sage/rings/numbers_abc.py +58 -0
  80. sage/rings/polynomial/all.py +22 -0
  81. sage/rings/polynomial/convolution.py +421 -0
  82. sage/symbolic/all__sagemath_standard_no_symbolics.py +0 -0
@@ -0,0 +1,686 @@
1
+ r"""
2
+ Interface to MuPAD
3
+
4
+ AUTHOR:
5
+
6
+ - Mike Hansen
7
+ - William Stein
8
+
9
+ You must have the optional commercial MuPAD interpreter installed and
10
+ available as the command \code{mupkern} in your PATH in order to use
11
+ this interface. You do not have to install any optional \sage
12
+ packages.
13
+
14
+ TESTS::
15
+
16
+ sage: # optional - mupad
17
+ sage: mupad.package('"MuPAD-Combinat"')
18
+ sage: combinat = mupad.combinat
19
+ sage: examples = mupad.examples
20
+ sage: S = examples.SymmetricFunctions()
21
+ sage: S.s[2,1]^2
22
+ s[3, 3] + s[4, 2] + s[2, 2, 1, 1] + s[2, 2, 2] + 2 s[3, 2, 1] + s[4, 1, 1] +
23
+ s[3, 1, 1, 1]
24
+ sage: S.omega( S.s[3] )
25
+ s[1, 1, 1]
26
+ sage: s = S.s
27
+ sage: p = S.p
28
+ sage: s(s[2,1] + p[2,1])
29
+ s[2, 1] + s[3] - s[1, 1, 1]
30
+ sage: s(_)
31
+ s[2, 1] + s[3] - s[1, 1, 1]
32
+
33
+ sage: # optional - mupad
34
+ sage: combinat.tableaux.list(3)
35
+ -- +---+ --
36
+ | | 3 | |
37
+ | +---+ +---+ +---+ |
38
+ | | 3 | | 2 | | 2 | |
39
+ | +---+---+---+ +---+---+ +---+---+ +---+ |
40
+ | | 1 | 2 | 3 |, | 1 | 2 |, | 1 | 3 |, | 1 | |
41
+ -- +---+---+---+ +---+---+ +---+---+ +---+ --
42
+ sage: three = mupad(3)
43
+ sage: three.combinat.tableaux.list()
44
+ -- +---+ --
45
+ | | 3 | |
46
+ | +---+ +---+ +---+ |
47
+ | | 3 | | 2 | | 2 | |
48
+ | +---+---+---+ +---+---+ +---+---+ +---+ |
49
+ | | 1 | 2 | 3 |, | 1 | 2 |, | 1 | 3 |, | 1 | |
50
+ -- +---+---+---+ +---+---+ +---+---+ +---+ --
51
+ sage: t = _[1]
52
+ sage: t
53
+ +---+---+---+
54
+ | 1 | 2 | 3 |
55
+ +---+---+---+
56
+ sage: combinat.tableaux.conjugate(t)
57
+ +---+
58
+ | 3 |
59
+ +---+
60
+ | 2 |
61
+ +---+
62
+ | 1 |
63
+ +---+
64
+
65
+ sage: # optional - mupad
66
+ sage: combinat.ribbonsTableaux.list([2,2],[1,1],2)
67
+ -- +---+---+ +---+---+ --
68
+ | | | 2 | | 2 | |
69
+ | + + +, +---+---+ |
70
+ | | 1 | | | 1 | |
71
+ -- +---+---+ +---+---+ --
72
+ sage: combinat.tableaux.kAtom([2,1],3)
73
+ -- +---+ --
74
+ | | 2 | |
75
+ | +---+---+ |
76
+ | | 1 | 1 | |
77
+ -- +---+---+ --
78
+ sage: M = S.Macdonald()
79
+ sage: a = M.P[1]^2
80
+ sage: mupad.mapcoeffs(a, 'normal')
81
+ q - t + q t - 1
82
+ P[2] + --------------- P[1, 1]
83
+ q t - 1
84
+ """
85
+
86
+ # **************************************************************************
87
+ # Copyright (C) 2008 Mike Hansen <mhansen@gmail.com>
88
+ # William Stein <wstein@gmail.com>
89
+ #
90
+ # Distributed under the terms of the GNU General Public License (GPL)
91
+ #
92
+ # https://www.gnu.org/licenses/
93
+ # **************************************************************************
94
+
95
+ import os
96
+
97
+ from .expect import (Expect, ExpectElement, ExpectFunction,
98
+ FunctionElement)
99
+ from sage.interfaces.interface import AsciiArtString
100
+ from sage.interfaces.tab_completion import ExtraTabCompletion
101
+ from sage.env import DOT_SAGE
102
+ from sage.misc.instancedoc import instancedoc
103
+
104
+ COMMANDS_CACHE = '%s/mupad_commandlist_cache.sobj' % DOT_SAGE
105
+ PROMPT = ">>"
106
+ seq = 0
107
+
108
+
109
+ class Mupad(ExtraTabCompletion, Expect):
110
+ """
111
+ Interface to the MuPAD interpreter.
112
+ """
113
+ def __init__(self, maxread=None, script_subdirectory=None, server=None, server_tmpdir=None, logfile=None):
114
+ """
115
+ Create an instance of the MuPAD interpreter.
116
+
117
+ EXAMPLES::
118
+
119
+ sage: mupad == loads(dumps(mupad)) # optional - mupad
120
+ True
121
+ """
122
+ Expect.__init__(self,
123
+ name='MuPAD',
124
+ prompt=PROMPT,
125
+ # the -U SAGE=TRUE allows for MuPAD programs to test whether they are run from Sage
126
+ command="mupkern -P e -U SAGE=TRUE",
127
+ script_subdirectory=script_subdirectory,
128
+ server=server,
129
+ server_tmpdir=server_tmpdir,
130
+ restart_on_ctrlc=False,
131
+ verbose_start=False,
132
+ logfile=None)
133
+
134
+ def _function_class(self):
135
+ """
136
+ EXAMPLES::
137
+
138
+ sage: mupad._function_class()
139
+ <class 'sage.interfaces.mupad.MupadFunction'>
140
+
141
+ sage: mdiff = mupad.diff; mdiff # optional - mupad
142
+ diff
143
+ sage: type(mdiff) # optional -- mupad
144
+ <class 'sage.interfaces.mupad.MupadFunction'>
145
+ """
146
+ return MupadFunction
147
+
148
+ def __reduce__(self):
149
+ """
150
+ EXAMPLES::
151
+
152
+ sage: Mupad().__reduce__()
153
+ (<function reduce_load_mupad at 0x...>, ())
154
+ """
155
+ return reduce_load_mupad, tuple([])
156
+
157
+ def _read_in_file_command(self, filename):
158
+ r"""
159
+ EXAMPLES::
160
+
161
+ sage: mupad._read_in_file_command('test')
162
+ 'read("test")'
163
+
164
+ sage: filename = tmp_filename()
165
+ sage: with open(filename, 'w') as f:
166
+ ....: _ = f.write('x := 2;\n')
167
+ sage: mupad.read(filename) # optional - MuPAD
168
+ sage: mupad.get('x').strip() # optional - mupad
169
+ '2'
170
+ """
171
+ return 'read("%s")' % filename
172
+
173
+ def _quit_string(self):
174
+ """
175
+ EXAMPLES::
176
+
177
+ sage: mupad._quit_string()
178
+ 'quit'
179
+ """
180
+ return 'quit'
181
+
182
+ def _install_hints(self):
183
+ """
184
+ Hints for installing MuPAD on your computer.
185
+
186
+ EXAMPLES::
187
+
188
+ sage: print(mupad._install_hints())
189
+ <BLANKLINE>
190
+ In order to use the MuPAD interface you need to have MuPAD installed
191
+ ...
192
+ """
193
+ return """
194
+ In order to use the MuPAD interface you need to have MuPAD installed
195
+ and have a script in your PATH called "mupkern" that runs the
196
+ command-line version of MuPAD.
197
+
198
+ (1) You might have to buy MuPAD.
199
+
200
+ (2) * LINUX: The mupkern script comes standard with your Mupad install.
201
+
202
+ * APPLE OS X:
203
+ ???
204
+ """
205
+
206
+ def expect(self):
207
+ """
208
+ EXAMPLES::
209
+
210
+ sage: a = mupad(1) # optional - mupad
211
+ sage: mupad.expect() # optional - mupad
212
+ <pexpect.spawn instance at 0x...>
213
+ """
214
+ return self._expect
215
+
216
+ def console(self):
217
+ """
218
+ Spawn a new MuPAD command-line session.
219
+
220
+ EXAMPLES::
221
+
222
+ sage: mupad.console() #not tested
223
+
224
+ *----* MuPAD Pro 4.0.2 -- The Open Computer Algebra System
225
+ /| /|
226
+ *----* | Copyright (c) 1997 - 2007 by SciFace Software
227
+ | *--|-* All rights reserved.
228
+ |/ |/
229
+ *----* Licensed to: ...
230
+ """
231
+ mupad_console()
232
+
233
+ def eval(self, code, strip=True, **kwds):
234
+ """
235
+ EXAMPLES::
236
+
237
+ sage: mupad.eval('2+2') # optional - mupad
238
+ 4
239
+ """
240
+ s = Expect.eval(self, code, **kwds)
241
+ return AsciiArtString(s)
242
+
243
+ def _eval_line(self, line, allow_use_file=True, wait_for_prompt=True,
244
+ need_output=True, restart_if_needed=False):
245
+ """
246
+ EXAMPLES::
247
+
248
+ sage: mupad._eval_line('2+2') # optional - mupad
249
+ ' 4'
250
+ sage: mupad._eval_line('x::asdf') # optional - mupad
251
+ Traceback (most recent call last):
252
+ ...
253
+ RuntimeError: Unknown slot "x::asdf" [slot]
254
+ """
255
+ if self._expect is None:
256
+ self._start()
257
+ if not need_output:
258
+ E = self._expect
259
+ E.sendline(line)
260
+ return
261
+
262
+ global seq
263
+ seq += 1
264
+ START = '__start__(%s+1)' % seq
265
+ END = '__end__(%s+1)' % seq
266
+ line = '%s; %s; %s;' % (START, line, END)
267
+ START = '__start__(%s)' % (seq+1)
268
+ END = '__end__(%s)' % (seq+1)
269
+
270
+ E = self._expect
271
+ E.sendline(line)
272
+ E.expect(PROMPT)
273
+ z = E.before
274
+ i = z.find(START)
275
+ if i == -1:
276
+ raise RuntimeError("%s\nError evaluating code in MuPAD" % z)
277
+ z = z[i+len(START)+2:]
278
+ z = z.rstrip().rstrip(END).rstrip('"').rstrip().strip('\n').strip('\r').strip('\n').replace('\\\r\n', '')
279
+ i = z.find('Error: ')
280
+ if i != -1:
281
+ raise RuntimeError(z[i + 7:])
282
+ return z
283
+
284
+ def cputime(self, t=None):
285
+ """
286
+ EXAMPLES::
287
+
288
+ sage: t = mupad.cputime() #random, optional - MuPAD
289
+ 0.11600000000000001
290
+ """
291
+ if t is None:
292
+ return float(str(self('time()')))/1000
293
+ else:
294
+ return float(str(self('time() - %s' % float(t))))/1000
295
+
296
+ def set(self, var, value):
297
+ """
298
+ Set the variable var to the given value.
299
+
300
+ EXAMPLES::
301
+
302
+ sage: mupad.set('a', 4) # optional - mupad
303
+ sage: mupad.get('a').strip() # optional - mupad
304
+ '4'
305
+ """
306
+ cmd = '%s:=%s:' % (var, value)
307
+ out = self.eval(cmd)
308
+ i = out.find('Error: ')
309
+ if i != -1:
310
+ raise RuntimeError(out[i + 7:])
311
+
312
+ def get(self, var):
313
+ """
314
+ Get the value of the variable var.
315
+
316
+ EXAMPLES::
317
+
318
+ sage: mupad.set('a', 4) # optional - mupad
319
+ sage: mupad.get('a').strip() # optional - mupad
320
+ '4'
321
+ """
322
+ s = self.eval('%s' % var)
323
+ i = s.find('=')
324
+ return s[i+1:]
325
+
326
+ def _object_class(self):
327
+ """
328
+ EXAMPLES::
329
+
330
+ sage: mupad._object_class()
331
+ <class 'sage.interfaces.mupad.MupadElement'>
332
+ """
333
+ return MupadElement
334
+
335
+ def _equality_symbol(self):
336
+ """
337
+ EXAMPLES::
338
+
339
+ sage: mupad._equality_symbol()
340
+ '='
341
+ """
342
+ return '='
343
+
344
+ def _assign_symbol(self):
345
+ """
346
+ EXAMPLES::
347
+
348
+ sage: mupad._assign_symbol()
349
+ ':='
350
+ """
351
+ return ":="
352
+
353
+ def _continuation_prompt(self):
354
+ """
355
+ EXAMPLES::
356
+
357
+ sage: mupad._continuation_prompt()
358
+ '&>'
359
+ """
360
+ return "&>"
361
+
362
+ def _commands(self):
363
+ """
364
+ Return list of all commands defined in MuPAD.
365
+
366
+ EXAMPLES::
367
+
368
+ sage: cmds = mupad._commands() # optional - mupad
369
+ sage: len(cmds) > 100 # optional - mupad
370
+ True
371
+ sage: 'diff' in cmds # optional - mupad
372
+ True
373
+ """
374
+ try:
375
+ v = sum([self.completions(chr(65+n)) for n in range(26)], []) + \
376
+ sum([self.completions(chr(97+n)) for n in range(26)], [])
377
+ except RuntimeError:
378
+ print("\n" * 3)
379
+ print("*" * 70)
380
+ print("WARNING: You do not have a working version of MuPAD installed!")
381
+ print("*" * 70)
382
+ v = []
383
+ v.sort()
384
+ return v
385
+
386
+ def _tab_completion(self, verbose=True, use_disk_cache=True):
387
+ """
388
+ EXAMPLES::
389
+
390
+ sage: names = mupad._tab_completion() # optional - mupad
391
+ sage: len(names) > 100 # optional - mupad
392
+ True
393
+ sage: 'combinat' in names # optional - mupad
394
+ True
395
+ """
396
+ try:
397
+ return self.__tab_completion
398
+ except AttributeError:
399
+ import sage.misc.persist
400
+ if use_disk_cache:
401
+ try:
402
+ self.__tab_completion = sage.misc.persist.load(COMMANDS_CACHE)
403
+ return self.__tab_completion
404
+ except OSError:
405
+ pass
406
+ if verbose:
407
+ print("\nBuilding MuPAD command completion list (this takes")
408
+ print("a few seconds only the first time you do it).")
409
+ print("To force rebuild later, delete %s." % COMMANDS_CACHE)
410
+ v = self._commands()
411
+ self.__tab_completion = v
412
+ if len(v) > 200:
413
+ # MuPAD is actually installed.
414
+ sage.misc.persist.save(v, COMMANDS_CACHE)
415
+ return v
416
+
417
+ def completions(self, string, strip=False):
418
+ """
419
+ EXAMPLES::
420
+
421
+ sage: mupad.completions('linal') # optional - mupad
422
+ ['linalg']
423
+ """
424
+ res = self.eval('_pref(Complete)("%s")' % string).strip()
425
+ res = res.replace('\n', '').split(',')
426
+ res = [s.strip().strip('"') for s in res]
427
+ res = [s for s in res if not s.endswith('::')]
428
+ if strip:
429
+ n = len(string)
430
+ res = [s[n:] for s in res]
431
+
432
+ return res if res != [''] else []
433
+
434
+
435
+ @instancedoc
436
+ class MupadFunction(ExtraTabCompletion, ExpectFunction):
437
+ def _instancedoc_(self):
438
+ """
439
+ EXAMPLES::
440
+
441
+ sage: mupad.diff.__doc__
442
+ No help on diff available
443
+ """
444
+ M = self._parent
445
+ return M.help(self._name)
446
+
447
+ def __getattr__(self, attrname):
448
+ """
449
+ EXAMPLES::
450
+
451
+ sage: mupad.linalg.addRow
452
+ linalg::addRow
453
+ """
454
+ if attrname[:1] == "_":
455
+ raise AttributeError
456
+ return MupadFunction(self._parent, self._name+"::"+attrname)
457
+
458
+ def _tab_completion(self):
459
+ """
460
+ EXAMPLES::
461
+
462
+ sage: mupad.linalg._tab_completion() # optional - mupad
463
+ ['addCol',
464
+ 'addRow',
465
+ ...
466
+ 'wiedemann']
467
+ """
468
+ res = self._parent.completions(self._name+"::", strip=True)
469
+ return res if res != [] else self._parent._tab_completion()
470
+
471
+
472
+ @instancedoc
473
+ class MupadFunctionElement(ExtraTabCompletion, FunctionElement):
474
+ def _instancedoc_(self):
475
+ """
476
+ EXAMPLES::
477
+
478
+ sage: x = mupad('x') # optional - mupad
479
+ sage: x.diff.__doc__ # optional - mupad
480
+ No help on diff available
481
+ """
482
+ return self._obj.parent().help(self._name)
483
+
484
+ def __getattr__(self, attrname):
485
+ """
486
+ EXAMPLES::
487
+
488
+ sage: # optional - mupad
489
+ sage: mupad.package('"MuPAD-Combinat"')
490
+ sage: combinat = mupad.combinat
491
+ sage: three = mupad(3)
492
+ sage: type(three.combinat)
493
+ <class 'sage.interfaces.mupad.MupadFunctionElement'>
494
+ sage: tableaux = three.combinat.tableaux
495
+ sage: type(tableaux)
496
+ <class 'sage.interfaces.mupad.MupadFunctionElement'>
497
+ """
498
+ P = self._obj.parent()
499
+ if attrname[:1] == "_":
500
+ if attrname not in self.__dict__:
501
+ raise AttributeError
502
+ else:
503
+ return self.__dict__[attrname]
504
+ name = self._name+"::"+attrname
505
+ if P.eval('type(%s)' % name) == "DOM_DOMAIN":
506
+ return MupadElement(P, name)
507
+ else:
508
+ return MupadFunctionElement(self._obj, name)
509
+
510
+ def _tab_completion(self):
511
+ """
512
+ EXAMPLES::
513
+
514
+ sage: three = mupad(3) # optional - mupad
515
+ sage: 'list' in three.combinat.tableaux._tab_completion() # optional - mupad
516
+ True
517
+ """
518
+ P = self._obj.parent()
519
+ res = P.completions(self._name+"::", strip=True)
520
+ return res if res != [] else P._tab_completion()
521
+
522
+ def __call__(self, *args):
523
+ """
524
+ EXAMPLES::
525
+
526
+ sage: # optional - mupad
527
+ sage: mupad.package('"MuPAD-Combinat"')
528
+ sage: combinat = mupad.combinat
529
+ sage: examples = mupad.examples
530
+ sage: S = examples.SymmetricFunctions()
531
+ sage: type(S.omega)
532
+ <class 'sage.interfaces.mupad.MupadFunctionElement'>
533
+ sage: S.omega(S.s[3])
534
+ s[1, 1, 1]
535
+ """
536
+ P = self._obj.parent()
537
+ if P.eval('type(%s)' % (self._obj.name())).strip() == "DOM_DOMAIN":
538
+ return P.function_call(self._name, list(args))
539
+ else:
540
+ return P.function_call(self._name, [self._obj] + list(args))
541
+
542
+
543
+ @instancedoc
544
+ class MupadElement(ExtraTabCompletion, ExpectElement):
545
+
546
+ def __getattr__(self, attrname):
547
+ """
548
+ EXAMPLES::
549
+
550
+ sage: # optional - mupad
551
+ sage: mupad.package('"MuPAD-Combinat"')
552
+ sage: S = mupad.examples.SymmetricFunctions()
553
+ sage: type(S)
554
+ <class 'sage.interfaces.mupad.MupadElement'>
555
+ sage: S.s
556
+ (examples::SymmetricFunctions(Dom::ExpressionField()))::s
557
+
558
+ sage: x = mupad('x') # optional - mupad-Combinat
559
+ sage: x.diff(x) # optional - mupad-Combinat
560
+ 1
561
+ """
562
+ if attrname[:1] == "_":
563
+ if attrname not in self.__dict__:
564
+ raise AttributeError
565
+ else:
566
+ return self.__dict__[attrname]
567
+ P = self.parent()
568
+
569
+ name = self._name + "::" + attrname
570
+ try:
571
+ if P.eval('type(%s::%s)' % (self.name(), attrname)).strip() == "DOM_DOMAIN":
572
+ return P.new("%s::%s" % (self.name(), attrname))
573
+ else:
574
+ return MupadFunctionElement(self, name)
575
+ except RuntimeError as err:
576
+ if 'Unknown slot' in str(err):
577
+ return MupadFunctionElement(self, attrname)
578
+ else:
579
+ raise err
580
+
581
+ def _tab_completion(self):
582
+ """
583
+ EXAMPLES::
584
+
585
+ sage: mupad.package('"MuPAD-Combinat"') # optional - mupad-Combinat
586
+ sage: S = mupad.examples.SymmetricFunctions() # optional - mupad-Combinat
587
+ sage: 'HallLittlewood' in S._tab_completion() # optional - mupad-Combinat
588
+ True
589
+ """
590
+ res = self.parent().completions(self.name()+"::", strip=True)
591
+ return res if res != [] else self.parent()._tab_completion()
592
+
593
+ def _latex_(self):
594
+ r"""
595
+ EXAMPLES::
596
+
597
+ sage: mupad.package('"MuPAD-Combinat"') # optional - mupad-Combinat
598
+ sage: S = mupad.examples.SymmetricFunctions() # optional - mupad-Combinat
599
+ sage: latex(S) # optional - mupad-Combinat
600
+ \mathrm{examples}{::}\mathrm{SymmetricFunctions}\left(\mathbb{E}\right)
601
+ """
602
+ self._check_valid()
603
+ P = self.parent()
604
+ s = P._eval_line('generate::TeX(%s)' % self.name())
605
+ return s.replace('\\\\', '\\').strip().strip('"')
606
+
607
+ def __len__(self):
608
+ r"""
609
+ The analogue in MuPAD of Python's len is the method nops.
610
+
611
+ EXAMPLES::
612
+
613
+ sage: len(mupad([1,2,3])) # indirect doctest # optional - mupad
614
+ 3
615
+ sage: type(len(mupad([1,2,3]))) # optional - mupad
616
+ <... 'int'>
617
+
618
+ sage: len(mupad(4)) # optional - mupad
619
+ 1
620
+
621
+ Implementing this is necessary for using MuPAD's lists as
622
+ standard containers::
623
+
624
+ sage: list(map(ZZ, list(mupad([1,2,3])))) # optional - mupad
625
+ [1, 2, 3]
626
+
627
+ sage: [int(x) for x in mupad([1,2,3]) ] # optional - mupad
628
+ [1, 2, 3]
629
+
630
+ sage: [int(x) for x in mupad("{1,2,3,5}") ] # optional - mupad
631
+ [1, 2, 3, 5]
632
+ """
633
+ return mupad.nops(self)
634
+
635
+
636
+ # An instance
637
+ mupad = Mupad()
638
+
639
+
640
+ def reduce_load_mupad():
641
+ """
642
+ EXAMPLES::
643
+
644
+ sage: from sage.interfaces.mupad import reduce_load_mupad
645
+ sage: reduce_load_mupad()
646
+ Mupad
647
+ """
648
+ return mupad
649
+
650
+
651
+ def mupad_console():
652
+ """
653
+ Spawn a new MuPAD command-line session.
654
+
655
+ EXAMPLES::
656
+
657
+ sage: from sage.interfaces.mupad import mupad_console
658
+ sage: mupad_console() #not tested
659
+
660
+ *----* MuPAD Pro 4.0.2 -- The Open Computer Algebra System
661
+ /| /|
662
+ *----* | Copyright (c) 1997 - 2007 by SciFace Software
663
+ | *--|-* All rights reserved.
664
+ |/ |/
665
+ *----* Licensed to: ...
666
+ """
667
+ from sage.repl.rich_output.display_manager import get_display_manager
668
+ if not get_display_manager().is_in_terminal():
669
+ raise RuntimeError('Can use the console only in the terminal. Try %%mupad magics instead.')
670
+ os.system('mupkern')
671
+
672
+
673
+ def __doctest_cleanup():
674
+ """
675
+ EXAMPLES::
676
+
677
+ sage: from sage.interfaces.mupad import __doctest_cleanup
678
+ sage: m = mupad(2) # optional - mupad
679
+ sage: mupad.is_running() # optional - mupad
680
+ True
681
+ sage: __doctest_cleanup()
682
+ sage: mupad.is_running() # optional - mupad
683
+ False
684
+ """
685
+ import sage.interfaces.quit
686
+ sage.interfaces.quit.expect_quitall()