passagemath-standard-no-symbolics 10.6.45__cp313-cp313-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.
Files changed (83) hide show
  1. passagemath_standard_no_symbolics/__init__.py +1 -0
  2. passagemath_standard_no_symbolics-10.6.45.data/scripts/sage-grep +5 -0
  3. passagemath_standard_no_symbolics-10.6.45.data/scripts/sage-grepdoc +5 -0
  4. passagemath_standard_no_symbolics-10.6.45.data/scripts/sage-list-packages +103 -0
  5. passagemath_standard_no_symbolics-10.6.45.dist-info/METADATA +150 -0
  6. passagemath_standard_no_symbolics-10.6.45.dist-info/RECORD +83 -0
  7. passagemath_standard_no_symbolics-10.6.45.dist-info/WHEEL +6 -0
  8. passagemath_standard_no_symbolics-10.6.45.dist-info/top_level.txt +2 -0
  9. sage/all.py +207 -0
  10. sage/all_cmdline.py +36 -0
  11. sage/cli/__init__.py +61 -0
  12. sage/cli/__main__.py +5 -0
  13. sage/cli/eval_cmd.py +45 -0
  14. sage/cli/eval_cmd_test.py +25 -0
  15. sage/cli/interactive_shell_cmd.py +28 -0
  16. sage/cli/notebook_cmd.py +51 -0
  17. sage/cli/notebook_cmd_test.py +39 -0
  18. sage/cli/options.py +26 -0
  19. sage/cli/run_file_cmd.py +50 -0
  20. sage/cli/version_cmd.py +26 -0
  21. sage/databases/all.py +83 -0
  22. sage/databases/cubic_hecke_db.py +1527 -0
  23. sage/dynamics/all.py +31 -0
  24. sage/dynamics/surface_dynamics_deprecation.py +32 -0
  25. sage/ext_data/kenzo/CP2.txt +45 -0
  26. sage/ext_data/kenzo/CP3.txt +349 -0
  27. sage/ext_data/kenzo/CP4.txt +4774 -0
  28. sage/ext_data/kenzo/README.txt +49 -0
  29. sage/ext_data/kenzo/S4.txt +20 -0
  30. sage/ext_data/mwrank/PRIMES +1 -0
  31. sage/ext_data/nbconvert/postprocess.py +48 -0
  32. sage/ext_data/nbconvert/rst_sage.tpl +99 -0
  33. sage/ext_data/nodoctest +0 -0
  34. sage/ext_data/notebook-ipython/kernel.json.in +11 -0
  35. sage/ext_data/notebook-ipython/logo-64x64.png +0 -0
  36. sage/ext_data/notebook-ipython/logo.svg +352 -0
  37. sage/ext_data/valgrind/pyalloc.supp +58 -0
  38. sage/ext_data/valgrind/sage-additional.supp +417 -0
  39. sage/ext_data/valgrind/sage.supp +43 -0
  40. sage/ext_data/valgrind/valgrind-python.supp +480 -0
  41. sage/geometry/all.py +12 -0
  42. sage/groups/matrix_gps/pickling_overrides.py +110 -0
  43. sage/homology/tests.py +66 -0
  44. sage/interacts/algebra.py +20 -0
  45. sage/interacts/all.py +25 -0
  46. sage/interacts/calculus.py +24 -0
  47. sage/interacts/fractals.py +18 -0
  48. sage/interacts/geometry.py +19 -0
  49. sage/interacts/library.py +1950 -0
  50. sage/interacts/library_cython.cpython-313-darwin.so +0 -0
  51. sage/interacts/statistics.py +19 -0
  52. sage/interfaces/axiom.py +1002 -0
  53. sage/interfaces/kash.py +834 -0
  54. sage/interfaces/lie.py +950 -0
  55. sage/interfaces/matlab.py +413 -0
  56. sage/interfaces/mupad.py +686 -0
  57. sage/interfaces/octave.py +858 -0
  58. sage/interfaces/phc.py +943 -0
  59. sage/interfaces/psage.py +189 -0
  60. sage/interfaces/qsieve.py +4 -0
  61. sage/interfaces/r.py +2096 -0
  62. sage/interfaces/read_data.py +46 -0
  63. sage/interfaces/scilab.py +576 -0
  64. sage/interfaces/tests.py +81 -0
  65. sage/libs/all.py +11 -0
  66. sage/libs/cremona/__init__.py +0 -0
  67. sage/libs/mwrank/__init__.py +0 -0
  68. sage/logic/all.py +3 -0
  69. sage/logic/booleval.py +160 -0
  70. sage/logic/boolformula.py +1490 -0
  71. sage/logic/logic.py +856 -0
  72. sage/logic/logicparser.py +696 -0
  73. sage/logic/logictable.py +272 -0
  74. sage/logic/propcalc.py +311 -0
  75. sage/misc/all.py +28 -0
  76. sage/misc/lazy_attribute.pyi +11 -0
  77. sage/rings/all.py +48 -0
  78. sage/rings/commutative_algebra.py +38 -0
  79. sage/rings/finite_rings/all.py +21 -0
  80. sage/rings/numbers_abc.py +58 -0
  81. sage/rings/polynomial/all.py +22 -0
  82. sage/rings/polynomial/convolution.py +421 -0
  83. sage/symbolic/all__sagemath_standard_no_symbolics.py +0 -0
sage/interfaces/lie.py ADDED
@@ -0,0 +1,950 @@
1
+ r"""
2
+ Interface to LiE
3
+
4
+ LiE is a software package under development at CWI since
5
+ January 1988. Its purpose is to enable mathematicians and
6
+ physicists to obtain on-line information as well as to
7
+ interactively perform computations of a Lie group theoretic
8
+ nature. It focuses on the representation theory of complex
9
+ semisimple (reductive) Lie groups and algebras, and on the
10
+ structure of their Weyl groups and root systems.
11
+
12
+ Type ``lie.[tab]`` for a list of all the functions available
13
+ from your LiE install. Type ``lie.[tab]?`` for LiE's
14
+ help about a given function. Type ``lie(...)`` to create
15
+ a new LiE object, and ``lie.eval(...)`` to run a string
16
+ using LiE (and get the result back as a string).
17
+
18
+ To access the LiE interpreter directly, run lie_console().
19
+
20
+ EXAMPLES::
21
+
22
+ sage: a4 = lie('A4') # optional - lie
23
+ sage: lie.diagram('A4') # optional - lie
24
+ O---O---O---O
25
+ 1 2 3 4
26
+ A4
27
+
28
+ sage: lie.diagram(a4) # optional - lie
29
+ O---O---O---O
30
+ 1 2 3 4
31
+ A4
32
+
33
+ sage: a4.diagram() # optional - lie
34
+ O---O---O---O
35
+ 1 2 3 4
36
+ A4
37
+
38
+ sage: a4.Cartan() # optional - lie
39
+ [[ 2,-1, 0, 0]
40
+ ,[-1, 2,-1, 0]
41
+ ,[ 0,-1, 2,-1]
42
+ ,[ 0, 0,-1, 2]
43
+ ]
44
+ sage: lie.LR_tensor([3,1],[2,2]) # optional - lie
45
+ 1X[5,3]
46
+
47
+
48
+ Tutorial
49
+ --------
50
+
51
+ The following examples are taken from Section 2.1 of the LiE manual.
52
+
53
+ You can perform basic arithmetic operations in LiE. ::
54
+
55
+ sage: # optional - lie
56
+ sage: lie.eval('19+68')
57
+ '87'
58
+ sage: a = lie('1111111111*1111111111')
59
+ sage: a
60
+ 1234567900987654321
61
+ sage: a/1111111111
62
+ 1111111111
63
+ sage: a = lie('345')
64
+ sage: a^2+3*a-5
65
+ 120055
66
+ sage: _ / 7*a
67
+ 5916750
68
+
69
+ Vectors in LiE are created using square brackets. Notice that
70
+ the indexing in LiE is 1-based, unlike Python/Sage which is 0-based. ::
71
+
72
+ sage: # optional - lie
73
+ sage: v = lie('[3,2,6873,-38]')
74
+ sage: v
75
+ [3,2,6873,-38]
76
+ sage: v[3]
77
+ 6873
78
+ sage: v+v
79
+ [6,4,13746,-76]
80
+ sage: v*v
81
+ 47239586
82
+ sage: v+234786
83
+ [3,2,6873,-38,234786]
84
+ sage: v-3
85
+ [3,2,-38]
86
+ sage: v^v
87
+ [3,2,6873,-38,3,2,6873,-38]
88
+
89
+ You can also work with matrices in LiE. ::
90
+
91
+ sage: m = lie('[[1,0,3,3],[12,4,-4,7],[-1,9,8,0],[3,-5,-2,9]]') # optional - lie
92
+ sage: m # optional - lie
93
+ [[ 1, 0, 3,3]
94
+ ,[12, 4,-4,7]
95
+ ,[-1, 9, 8,0]
96
+ ,[ 3,-5,-2,9]
97
+ ]
98
+ sage: print(lie.eval('*'+m._name)) # optional - lie
99
+ [[1,12,-1, 3]
100
+ ,[0, 4, 9,-5]
101
+ ,[3,-4, 8,-2]
102
+ ,[3, 7, 0, 9]
103
+ ]
104
+
105
+ sage: # optional - lie
106
+ sage: m^3
107
+ [[ 220, 87, 81, 375]
108
+ ,[-168,-1089, 13,1013]
109
+ ,[1550, 357,-55,1593]
110
+ ,[-854, -652, 98,-170]
111
+ ]
112
+ sage: v*m
113
+ [-6960,62055,55061,-319]
114
+ sage: m*v
115
+ [20508,-27714,54999,-14089]
116
+ sage: v*m*v
117
+ 378549605
118
+ sage: m+v
119
+ [[ 1, 0, 3, 3]
120
+ ,[12, 4, -4, 7]
121
+ ,[-1, 9, 8, 0]
122
+ ,[ 3,-5, -2, 9]
123
+ ,[ 3, 2,6873,-38]
124
+ ]
125
+
126
+ sage: m-2 # optional - lie
127
+ [[ 1, 0, 3,3]
128
+ ,[-1, 9, 8,0]
129
+ ,[ 3,-5,-2,9]
130
+ ]
131
+
132
+
133
+ LiE handles multivariate (Laurent) polynomials. ::
134
+
135
+ sage: # optional - lie
136
+ sage: lie('X[1,2]')
137
+ 1X[1,2]
138
+ sage: -3*_
139
+ -3X[1,2]
140
+ sage: _ + lie('4X[-1,4]')
141
+ 4X[-1,4] - 3X[ 1,2]
142
+ sage: _^2
143
+ 16X[-2,8] - 24X[ 0,6] + 9X[ 2,4]
144
+ sage: lie('(4X[-1,4]-3X[1,2])*(X[2,0]-X[0,-4])')
145
+ -4X[-1, 0] + 3X[ 1,-2] + 4X[ 1, 4] - 3X[ 3, 2]
146
+ sage: _ - _
147
+ 0X[0,0]
148
+
149
+
150
+ You can call LiE's built-in functions using ``lie.functionname``. ::
151
+
152
+ sage: lie.partitions(6) # optional - lie
153
+ [[6,0,0,0,0,0]
154
+ ,[5,1,0,0,0,0]
155
+ ,[4,2,0,0,0,0]
156
+ ,[4,1,1,0,0,0]
157
+ ,[3,3,0,0,0,0]
158
+ ,[3,2,1,0,0,0]
159
+ ,[3,1,1,1,0,0]
160
+ ,[2,2,2,0,0,0]
161
+ ,[2,2,1,1,0,0]
162
+ ,[2,1,1,1,1,0]
163
+ ,[1,1,1,1,1,1]
164
+ ]
165
+ sage: lie.diagram('E8') # optional - lie
166
+ O 2
167
+ |
168
+ |
169
+ O---O---O---O---O---O---O
170
+ 1 3 4 5 6 7 8
171
+ E8
172
+
173
+
174
+ You can define your own functions in LiE using lie.eval . Once you've defined
175
+ a function (say f), you can call it using lie.f ; however, user-defined functions
176
+ do not show up when using tab-completion. ::
177
+
178
+ sage: # optional - lie
179
+ sage: lie.eval('f(int x) = 2*x')
180
+ ''
181
+ sage: lie.f(984)
182
+ 1968
183
+ sage: lie.eval('f(int n) = a=3*n-7; if a < 0 then a = -a fi; 7^a+a^3-4*a-57')
184
+ ''
185
+ sage: lie.f(2)
186
+ -53
187
+ sage: lie.f(5)
188
+ 5765224
189
+
190
+
191
+ LiE's help can be accessed through lie.help('functionname') where
192
+ functionname is the function you want to receive help for. ::
193
+
194
+ sage: print(lie.help('diagram')) # optional - lie
195
+ diagram(g). Prints the Dynkin diagram of g, also indicating
196
+ the type of each simple component printed, and labeling the nodes as
197
+ done by Bourbaki (for the second and further simple components the
198
+ labels are given an offset so as to make them disjoint from earlier
199
+ labels). The labeling of the vertices of the Dynkin diagram prescribes
200
+ the order of the coordinates of root- and weight vectors used in LiE.
201
+
202
+ This can also be accessed with lie.functionname? .
203
+
204
+
205
+ With the exception of groups, all LiE data types can be converted into
206
+ native Sage data types by calling the .sage() method.
207
+
208
+ Integers::
209
+
210
+ sage: a = lie('1234') # optional - lie
211
+ sage: b = a.sage(); b # optional - lie
212
+ 1234
213
+ sage: type(b) # optional - lie
214
+ <class 'sage.rings.integer.Integer'>
215
+
216
+ Vectors::
217
+
218
+ sage: a = lie('[1,2,3]') # optional - lie
219
+ sage: b = a.sage(); b # optional - lie
220
+ [1, 2, 3]
221
+ sage: type(b) # optional - lie
222
+ <... 'list'>
223
+
224
+ Matrices::
225
+
226
+ sage: a = lie('[[1,2],[3,4]]') # optional - lie
227
+ sage: b = a.sage(); b # optional - lie
228
+ [1 2]
229
+ [3 4]
230
+ sage: type(b) # optional - lie
231
+ <class 'sage.matrix.matrix_integer_dense.Matrix_integer_dense'>
232
+
233
+ Polynomials::
234
+
235
+ sage: a = lie('X[1,2] - 2*X[2,1]') # optional - lie
236
+ sage: b = a.sage(); b # optional - lie
237
+ -2*x0^2*x1 + x0*x1^2
238
+ sage: type(b) # optional - lie
239
+ <class 'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular'>
240
+
241
+ Text::
242
+
243
+ sage: a = lie('"text"') # optional - lie
244
+ sage: b = a.sage(); b # optional - lie
245
+ 'text'
246
+ sage: type(b) # optional - lie
247
+ <... 'str'>
248
+
249
+
250
+ LiE can be programmed using the Sage interface as well. Section 5.1.5
251
+ of the manual gives an example of a function written in LiE's language
252
+ which evaluates a polynomial at a point. Below is a (roughly) direct
253
+ translation of that program into Python / Sage. ::
254
+
255
+ sage: # optional - lie
256
+ sage: def eval_pol(p, pt):
257
+ ....: s = 0
258
+ ....: for i in range(1,p.length().sage()+1):
259
+ ....: m = 1
260
+ ....: for j in range(1,pt.size().sage()+1):
261
+ ....: m *= pt[j]^p.expon(i)[j]
262
+ ....: s += p.coef(i)*m
263
+ ....: return s
264
+ sage: a = lie('X[1,2]')
265
+ sage: b1 = lie('[1,2]')
266
+ sage: b2 = lie('[2,3]')
267
+ sage: eval_pol(a, b1)
268
+ 4
269
+ sage: eval_pol(a, b2)
270
+ 18
271
+
272
+ AUTHORS:
273
+
274
+ - Mike Hansen 2007-08-27
275
+ - William Stein (template)
276
+ """
277
+
278
+ ##########################################################################
279
+ #
280
+ # Copyright (C) 2007 Mike Hansen <mhansen@gmail.com>
281
+ # Copyright (C) 2006 William Stein <wstein@gmail.com>
282
+ #
283
+ # Distributed under the terms of the GNU General Public License (GPL)
284
+ #
285
+ # https://www.gnu.org/licenses/
286
+ #
287
+ ##########################################################################
288
+ from itertools import chain
289
+ import os
290
+
291
+ from .expect import Expect, ExpectElement, ExpectFunction, FunctionElement
292
+ from sage.interfaces.interface import AsciiArtString
293
+ from sage.misc.misc_c import prod
294
+ from sage.env import DOT_SAGE, LIE_INFO_DIR
295
+ from sage.misc.sage_eval import sage_eval
296
+ from sage.interfaces.tab_completion import ExtraTabCompletion
297
+ from sage.misc.instancedoc import instancedoc
298
+
299
+
300
+ COMMANDS_CACHE = '%s/lie_commandlist_cache.sobj' % DOT_SAGE
301
+ HELP_CACHE = '%s/lie_helpdict_cache.sobj' % DOT_SAGE
302
+
303
+
304
+ class LiE(ExtraTabCompletion, Expect):
305
+ r"""
306
+ Interface to the LiE interpreter.
307
+
308
+ Type ``lie.[tab]`` for a list of all the functions available
309
+ from your LiE install. Type ``lie.[tab]?`` for LiE's
310
+ help about a given function. Type ``lie(...)`` to create
311
+ a new LiE object, and ``lie.eval(...)`` to run a string
312
+ using LiE (and get the result back as a string).
313
+ """
314
+
315
+ def __init__(self,
316
+ maxread=None, script_subdirectory=None,
317
+ logfile=None,
318
+ server=None):
319
+ """
320
+ EXAMPLES::
321
+
322
+ sage: lie == loads(dumps(lie))
323
+ True
324
+ """
325
+ Expect.__init__(self,
326
+
327
+ # The capitalized version of this is used for printing.
328
+ name='LiE',
329
+
330
+ # This is regexp of the input prompt. If you can change
331
+ # it to be very obfuscated that would be better. Even
332
+ # better is to use sequence numbers.
333
+ prompt='> ',
334
+
335
+ # This is the command that starts up your program
336
+ command="bash lie",
337
+
338
+ server=server,
339
+ script_subdirectory=script_subdirectory,
340
+
341
+ # If this is true, then whenever the user presses Control-C to
342
+ # interrupt a calculation, the whole interface is restarted.
343
+ restart_on_ctrlc=False,
344
+
345
+ # If true, print out a message when starting
346
+ # up the command when you first send a command
347
+ # to this interface.
348
+ verbose_start=False,
349
+
350
+ logfile=logfile,
351
+
352
+ # If an input is longer than this number of characters, then
353
+ # try to switch to outputting to a file.
354
+ eval_using_file_cutoff=1024)
355
+
356
+ self._seq = 0
357
+
358
+ self._tab_completion_dict = None
359
+ self._tab_completion_list = None
360
+ self._help_dict = None
361
+
362
+ def _read_info_files(self, use_disk_cache=True):
363
+ """
364
+ EXAMPLES::
365
+
366
+ sage: from sage.interfaces.lie import LiE
367
+ sage: lie = LiE()
368
+ sage: lie._tab_completion_list is None
369
+ True
370
+ sage: lie._read_info_files(use_disk_cache=False) #optional - lie
371
+ sage: lie._tab_completion_list # optional - lie
372
+ ['Adams',
373
+ ...
374
+ 'history',
375
+ ...
376
+ 'sort',
377
+ ...
378
+ 'version',
379
+ 'void',
380
+ 'write']
381
+ """
382
+ import sage.misc.persist
383
+ if use_disk_cache:
384
+ try:
385
+ trait_dict = sage.misc.persist.load(COMMANDS_CACHE)
386
+ help_dict = sage.misc.persist.load(HELP_CACHE)
387
+ v = []
388
+ for key in trait_dict:
389
+ v += trait_dict[key]
390
+ self._tab_completion_list = sorted(v)
391
+ self._tab_completion_dict = trait_dict
392
+ self._help_dict = help_dict
393
+ return
394
+ except OSError:
395
+ pass
396
+
397
+ # Go through INFO.3 and get the necessary information
398
+ filenames = ['INFO.3', 'INFO.0']
399
+ commands = {}
400
+ commands['vid'] = []
401
+ help = {}
402
+
403
+ for f in filenames:
404
+ info = open(os.path.join(LIE_INFO_DIR, f))
405
+ prev_command = ""
406
+ help_text = ""
407
+ for line in info:
408
+ # If the line doesn't start with an "@", then
409
+ # it is part of the help text for the previous
410
+ # command
411
+ if len(line) == 0 or line[0] != "@":
412
+ if prev_command != "":
413
+ help_text += line
414
+ continue
415
+
416
+ # Do not add not completions that do not start with an
417
+ # alphabetical character or that contain 'silence'
418
+ if len(line) > 1 and (not line[1].isalpha() or line.find('silence') != -1):
419
+ help[prev_command] = help.get(prev_command, "") + help_text
420
+ help_text = ""
421
+ prev_command = ""
422
+ continue
423
+
424
+ # At this point we should be at the start of a new
425
+ # command definition
426
+
427
+ # Get the type of the first argument of the command
428
+ i = line.find('(')
429
+ if line[i + 1] == ")":
430
+ t = 'vid'
431
+ else:
432
+ t = line[i + 1:i + 4]
433
+
434
+ # Save the help text for the command
435
+ help[prev_command] = help.get(prev_command, "") + help_text
436
+ help_text = ""
437
+ prev_command = line[1:i]
438
+
439
+ # Add the command
440
+ if t in commands:
441
+ commands[t].append(line[1:i])
442
+ else:
443
+ commands[t] = [line[1:i]]
444
+
445
+ # Take care of the last help text which doesn't get processed
446
+ # since there's no following @ symbol
447
+ help[prev_command] = help.get(prev_command, "") + help_text
448
+
449
+ info.close()
450
+
451
+ # Build the list of all possible command completions
452
+ l = list(chain(*commands.values()))
453
+
454
+ # Save the data
455
+ self._tab_completion_dict = commands
456
+ self._tab_completion_list = sorted(l)
457
+ self._help_dict = help
458
+
459
+ # Write them to file
460
+ if use_disk_cache:
461
+ sage.misc.persist.save(commands, COMMANDS_CACHE)
462
+ sage.misc.persist.save(help, HELP_CACHE)
463
+
464
+ def _repr_(self) -> str:
465
+ """
466
+ EXAMPLES::
467
+
468
+ sage: lie
469
+ LiE Interpreter
470
+ """
471
+ return 'LiE Interpreter'
472
+
473
+ def __reduce__(self):
474
+ """
475
+ EXAMPLES::
476
+
477
+ sage: LiE().__reduce__()
478
+ (<function reduce_load_lie at 0x...>, ())
479
+ """
480
+ return reduce_load_lie, tuple([])
481
+
482
+ def _function_class(self):
483
+ """
484
+ EXAMPLES::
485
+
486
+ sage: lie._function_class()
487
+ <class 'sage.interfaces.lie.LiEFunction'>
488
+ """
489
+ return LiEFunction
490
+
491
+ def _quit_string(self) -> str:
492
+ """
493
+ EXAMPLES::
494
+
495
+ sage: lie._quit_string()
496
+ 'quit'
497
+ """
498
+ return 'quit'
499
+
500
+ def _read_in_file_command(self, filename):
501
+ """
502
+ EXAMPLES::
503
+
504
+ sage: lie._read_in_file_command('testfile')
505
+ Traceback (most recent call last):
506
+ ...
507
+ NotImplementedError
508
+ """
509
+ raise NotImplementedError
510
+
511
+ def _tab_completion(self, type=None, verbose=False, use_disk_cache=True):
512
+ """
513
+ EXAMPLES::
514
+
515
+ sage: lie._tab_completion() # optional - lie
516
+ ['Adams',
517
+ ...
518
+ 'Cartan_type',
519
+ ...
520
+ 'cent_roots',
521
+ ...
522
+ 'n_comp',
523
+ ...
524
+ 'write']
525
+ """
526
+ if self._tab_completion_dict is None:
527
+ self._read_info_files()
528
+ if type:
529
+ return sorted(self._tab_completion_dict[type])
530
+ else:
531
+ return self._tab_completion_list
532
+
533
+ def _an_element_(self):
534
+ """
535
+ EXAMPLES::
536
+
537
+ sage: lie._an_element_() # optional - lie
538
+ 0
539
+ """
540
+ return self(0)
541
+
542
+ def read(self, filename):
543
+ r"""
544
+ EXAMPLES::
545
+
546
+ sage: filename = tmp_filename()
547
+ sage: with open(filename, 'w') as f:
548
+ ....: _ = f.write('x = 2\n')
549
+ sage: lie.read(filename) # optional - lie
550
+ sage: lie.get('x') # optional - lie
551
+ '2'
552
+ sage: import os
553
+ sage: os.unlink(filename)
554
+ """
555
+ self.eval('read %s' % filename)
556
+
557
+ def console(self):
558
+ """
559
+ Spawn a new LiE command-line session.
560
+
561
+ EXAMPLES::
562
+
563
+ sage: lie.console() # not tested
564
+ LiE version 2.2.2 created on Sep 26 2007 at 18:13:19
565
+ Authors: Arjeh M. Cohen, Marc van Leeuwen, Bert Lisser.
566
+ Free source code distribution
567
+ ...
568
+ """
569
+ lie_console()
570
+
571
+ def version(self) -> str:
572
+ """
573
+ EXAMPLES::
574
+
575
+ sage: lie.version() # optional - lie
576
+ '2...'
577
+ """
578
+ return lie_version()
579
+
580
+ def _object_class(self):
581
+ """
582
+ EXAMPLES::
583
+
584
+ sage: lie._object_class()
585
+ <class 'sage.interfaces.lie.LiEElement'>
586
+ """
587
+ return LiEElement
588
+
589
+ def _true_symbol(self) -> str:
590
+ """
591
+ EXAMPLES::
592
+
593
+ sage: lie._true_symbol()
594
+ '1'
595
+ """
596
+ return '1'
597
+
598
+ def _false_symbol(self) -> str:
599
+ """
600
+ EXAMPLES::
601
+
602
+ sage: lie._false_symbol()
603
+ '0'
604
+ """
605
+ return '0'
606
+
607
+ def _equality_symbol(self) -> str:
608
+ """
609
+ EXAMPLES::
610
+
611
+ sage: lie._equality_symbol()
612
+ '=='
613
+ """
614
+ return '=='
615
+
616
+ def help(self, command):
617
+ """
618
+ Return a string of the LiE help for command.
619
+
620
+ EXAMPLES::
621
+
622
+ sage: lie.help('diagram') # optional - lie
623
+ 'diagram(g)...'
624
+ """
625
+ # return help on a given command.
626
+ if self._help_dict is None:
627
+ self._read_info_files()
628
+ try:
629
+ return self._help_dict[command]
630
+ except KeyError:
631
+ return "Could not find help for " + command
632
+
633
+ def _eval_line(self, line, allow_use_file=True, wait_for_prompt=True, restart_if_needed=False):
634
+ """
635
+ EXAMPLES::
636
+
637
+ sage: lie._eval_line('2+2') # optional - lie
638
+ ' 4'
639
+ sage: lie._eval_line('diagram(2)') # optional - lie
640
+ Traceback (most recent call last):
641
+ ...
642
+ RuntimeError: An error occurred running a LiE command:
643
+ Argument types do not match in call. Types are: diagram(bin).
644
+ Valid argument types are for instance: diagram(grp).
645
+ """
646
+ out = Expect._eval_line(self, line, allow_use_file=allow_use_file, wait_for_prompt=wait_for_prompt)
647
+ # Check to see if an error has occurred
648
+ err = max(out.find("\n(in"), out.find('not defined'), out.find('Argument types'))
649
+ if err != -1:
650
+ raise RuntimeError("An error occurred running a LiE command:\n%s" % (out.replace('\r\n', '\n')))
651
+ return out
652
+
653
+ def eval(self, code, strip=True, **kwds):
654
+ """
655
+ EXAMPLES::
656
+
657
+ sage: lie.eval('2+2') # optional - lie
658
+ '4'
659
+ """
660
+ s = Expect.eval(self, code, strip=True, **kwds)
661
+ # return s.strip()
662
+ if len(s) > 0 and s.find("\n") != -1:
663
+ return s
664
+ else:
665
+ return s.strip()
666
+
667
+ def set(self, var, value):
668
+ """
669
+ Set the variable var to the given value.
670
+
671
+ EXAMPLES::
672
+
673
+ sage: lie.set('x', '2') # optional - lie
674
+ sage: lie.get('x') # optional - lie
675
+ '2'
676
+ """
677
+ cmd = '%s=%s' % (var, value)
678
+ out = self.eval(cmd)
679
+ i = min(out.find('not defined'), out.find(r'\(in'), out.find('Argument types'))
680
+ if i != -1:
681
+ raise RuntimeError(out)
682
+
683
+ def get(self, var):
684
+ """
685
+ Get the value of the variable var.
686
+
687
+ EXAMPLES::
688
+
689
+ sage: lie.set('x', '2') # optional - lie
690
+ sage: lie.get('x') # optional - lie
691
+ '2'
692
+ """
693
+ return self.eval('%s' % var)
694
+
695
+ def get_using_file(self, var):
696
+ """
697
+ EXAMPLES::
698
+
699
+ sage: lie.get_using_file('x')
700
+ Traceback (most recent call last):
701
+ ...
702
+ NotImplementedError
703
+ """
704
+ raise NotImplementedError
705
+
706
+ def function_call(self, function, args=None, kwds=None):
707
+ """
708
+ EXAMPLES::
709
+
710
+ sage: lie.function_call("diagram", args=['A4']) # optional - lie
711
+ O---O---O---O
712
+ 1 2 3 4
713
+ A4
714
+ """
715
+ # If function just prints something on the screen rather than
716
+ # returning an object, then we return an AsciiArtString rather
717
+ # than a LiEElement
718
+ if function in ['diagram', 'setdefault', 'print_tab', 'type', 'factor', 'void', 'gcol']:
719
+ args, kwds = self._convert_args_kwds(args, kwds)
720
+ cmd = "%s(%s)" % (function, ",".join(s.name() for s in args))
721
+ return AsciiArtString(self.eval(cmd))
722
+
723
+ return Expect.function_call(self, function, args, kwds)
724
+
725
+ def _function_element_class(self):
726
+ """
727
+ EXAMPLES::
728
+
729
+ sage: lie._function_element_class()
730
+ <class 'sage.interfaces.lie.LiEFunctionElement'>
731
+ """
732
+ return LiEFunctionElement
733
+
734
+
735
+ @instancedoc
736
+ class LiEElement(ExtraTabCompletion, ExpectElement):
737
+ def _tab_completion(self):
738
+ """
739
+ Return the possible tab completions for ``self``.
740
+
741
+ EXAMPLES::
742
+
743
+ sage: a4 = lie('A4') # optional - lie
744
+ sage: a4._tab_completion() # optional - lie
745
+ ['Cartan',
746
+ ...
747
+ 'center',
748
+ 'det_Cartan',
749
+ 'diagram',
750
+ ...
751
+ 'n_comp',
752
+ ...
753
+ 'res_mat']
754
+ """
755
+ return self.parent()._tab_completion(type=self.type())
756
+
757
+ def type(self):
758
+ """
759
+ EXAMPLES::
760
+
761
+ sage: m = lie('[[1,0,3,3],[12,4,-4,7],[-1,9,8,0],[3,-5,-2,9]]') # optional - lie
762
+ sage: m.type() # optional - lie
763
+ 'mat'
764
+ """
765
+ t = self.parent().eval('type(%s)' % self._name)
766
+ i = t.find(':')
767
+ return t[i + 1:].strip()
768
+
769
+ def _matrix_(self, R=None):
770
+ """
771
+ EXAMPLES::
772
+
773
+ sage: m = lie('[[1,0,3,3],[12,4,-4,7],[-1,9,8,0],[3,-5,-2,9]]') # optional - lie
774
+ sage: matrix(m) # optional - lie
775
+ [ 1 0 3 3]
776
+ [12 4 -4 7]
777
+ [-1 9 8 0]
778
+ [ 3 -5 -2 9]
779
+ sage: matrix(RDF, m) # optional - lie
780
+ [ 1.0 0.0 3.0 3.0]
781
+ [12.0 4.0 -4.0 7.0]
782
+ [-1.0 9.0 8.0 0.0]
783
+ [ 3.0 -5.0 -2.0 9.0]
784
+ """
785
+ self._check_valid()
786
+ if self.type() == 'mat':
787
+ m = self.sage()
788
+ if R is not None:
789
+ m = m.change_ring(R)
790
+ return m
791
+ else:
792
+ raise ValueError("not a matrix")
793
+
794
+ def _sage_(self):
795
+ """
796
+ EXAMPLES::
797
+
798
+ sage: m = lie('[[1,0,3,3],[12,4,-4,7],[-1,9,8,0],[3,-5,-2,9]]') # optional - lie
799
+ sage: m.sage() # optional - lie
800
+ [ 1 0 3 3]
801
+ [12 4 -4 7]
802
+ [-1 9 8 0]
803
+ [ 3 -5 -2 9]
804
+ sage: lie('-1X[1,1]').sage() # optional - lie
805
+ -x0*x1
806
+ """
807
+ t = self.type()
808
+ if t == 'grp':
809
+ raise ValueError("cannot convert Lie groups to native Sage objects")
810
+ elif t == 'mat':
811
+ import sage.matrix.constructor
812
+ data = sage_eval(str(self).replace('\n', '').strip())
813
+ return sage.matrix.constructor.matrix(data)
814
+ elif t == 'pol':
815
+ from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
816
+ from sage.rings.rational_field import QQ
817
+
818
+ # Figure out the number of variables
819
+ s = str(self)
820
+ open_bracket = s.find('[')
821
+ close_bracket = s.find(']')
822
+ nvars = len(s[open_bracket:close_bracket].split(','))
823
+
824
+ # create the polynomial ring
825
+ R = PolynomialRing(QQ, nvars, 'x')
826
+ x = R.gens()
827
+ pol = R.zero()
828
+
829
+ # Split up the polynomials into terms
830
+ terms = []
831
+ for termgrp in s.split(' - '):
832
+ # The first entry in termgrp has
833
+ # a negative coefficient
834
+ termgrp = "-" + termgrp.strip()
835
+ terms += termgrp.split('+')
836
+ # Make sure we don't accidentally add a negative
837
+ # sign to the first monomial
838
+ terms[0] = terms[0][1:]
839
+
840
+ # go through all the terms in s
841
+ for term in terms:
842
+ xpos = term.find('X')
843
+ coef = eval(term[:xpos].strip())
844
+ exps = eval(term[xpos + 1:].strip())
845
+ monomial = prod([x[i]**exps[i] for i in range(nvars)])
846
+ pol += coef * monomial
847
+
848
+ return pol
849
+ elif t == 'tex':
850
+ return repr(self)
851
+ elif t == 'vid':
852
+ return None
853
+ else:
854
+ return ExpectElement._sage_(self)
855
+
856
+
857
+ @instancedoc
858
+ class LiEFunctionElement(FunctionElement):
859
+ def _instancedoc_(self):
860
+ """
861
+ EXAMPLES::
862
+
863
+ sage: a4 = lie('A4') # optional - lie
864
+ sage: a4.diagram.__doc__ # optional - lie
865
+ 'diagram(g)...'
866
+ """
867
+ M = self._obj.parent()
868
+ return M.help(self._name)
869
+
870
+
871
+ @instancedoc
872
+ class LiEFunction(ExpectFunction):
873
+ def _instancedoc_(self):
874
+ """
875
+ Return the help for ``self``.
876
+
877
+ EXAMPLES::
878
+
879
+ sage: lie.diagram.__doc__ # optional - lie
880
+ 'diagram(g)...'
881
+ """
882
+ M = self._parent
883
+ return M.help(self._name)
884
+
885
+
886
+ def is_LiEElement(x) -> bool:
887
+ """
888
+ EXAMPLES::
889
+
890
+ sage: from sage.interfaces.lie import is_LiEElement
891
+ sage: is_LiEElement(2)
892
+ doctest:...: DeprecationWarning: the function is_LiEElement is deprecated; use isinstance(x, sage.interfaces.abc.LiEElement) instead
893
+ See https://github.com/sagemath/sage/issues/34804 for details.
894
+ False
895
+ sage: l = lie(2) # optional - lie
896
+ sage: is_LiEElement(l) # optional - lie
897
+ True
898
+ """
899
+ from sage.misc.superseded import deprecation
900
+ deprecation(34804, "the function is_LiEElement is deprecated; use isinstance(x, sage.interfaces.abc.LiEElement) instead")
901
+
902
+ return isinstance(x, LiEElement)
903
+
904
+
905
+ # An instance
906
+ lie = LiE()
907
+
908
+
909
+ def reduce_load_lie():
910
+ """
911
+ EXAMPLES::
912
+
913
+ sage: from sage.interfaces.lie import reduce_load_lie
914
+ sage: reduce_load_lie()
915
+ LiE Interpreter
916
+ """
917
+ return lie
918
+
919
+
920
+ def lie_console():
921
+ """
922
+ Spawn a new LiE command-line session.
923
+
924
+ EXAMPLES::
925
+
926
+ sage: from sage.interfaces.lie import lie_console
927
+ sage: lie_console() # not tested
928
+ LiE version 2.2.2 created on Sep 26 2007 at 18:13:19
929
+ Authors: Arjeh M. Cohen, Marc van Leeuwen, Bert Lisser.
930
+ Free source code distribution
931
+ ...
932
+ """
933
+ from sage.repl.rich_output.display_manager import get_display_manager
934
+ if not get_display_manager().is_in_terminal():
935
+ raise RuntimeError('Can use the console only in the terminal. Try %%lie magics instead.')
936
+ os.system('bash `which lie`')
937
+
938
+
939
+ def lie_version():
940
+ """
941
+ EXAMPLES::
942
+
943
+ sage: from sage.interfaces.lie import lie_version
944
+ sage: lie_version() # optional - lie
945
+ '2...'
946
+ """
947
+ with open(os.path.join(LIE_INFO_DIR, 'INFO.0')) as f:
948
+ lines = f.readlines()
949
+ i = lines.index('@version()\n')
950
+ return lines[i + 1].split()[1]