33
44
55from mathics .builtin import (
6- algebra , arithmetic , assignment , attributes , calculus , combinatorial , compilation ,
7- comparison , control , datentime , diffeqns , evaluation , exptrig , functional ,
8- graphics , graphics3d ,
9- image , inout , integer , iohooks , linalg , lists , logic ,
10- manipulate , quantities , numbertheory , numeric , options , patterns ,
11- plot , physchemdata , randomnumbers , recurrence , specialfunctions , scoping ,
12- strings , structure , system , tensors , xmlformat , optimization )
6+ algebra ,
7+ arithmetic ,
8+ assignment ,
9+ attributes ,
10+ calculus ,
11+ combinatorial ,
12+ compilation ,
13+ comparison ,
14+ constants ,
15+ control ,
16+ datentime ,
17+ diffeqns ,
18+ evaluation ,
19+ exptrig ,
20+ functional ,
21+ graphics ,
22+ graphics3d ,
23+ image ,
24+ inout ,
25+ integer ,
26+ iohooks ,
27+ linalg ,
28+ lists ,
29+ logic ,
30+ manipulate ,
31+ quantities ,
32+ numbertheory ,
33+ numeric ,
34+ options ,
35+ patterns ,
36+ plot ,
37+ physchemdata ,
38+ randomnumbers ,
39+ recurrence ,
40+ specialfunctions ,
41+ scoping ,
42+ strings ,
43+ structure ,
44+ system ,
45+ tensors ,
46+ xmlformat ,
47+ optimization ,
48+ )
1349
1450from mathics .builtin .base import (
15- Builtin , SympyObject , BoxConstruct , Operator , PatternObject )
51+ Builtin ,
52+ SympyObject ,
53+ BoxConstruct ,
54+ Operator ,
55+ PatternObject ,
56+ )
1657
1758from mathics .settings import ENABLE_FILES_MODULE
1859
1960modules = [
20- algebra , arithmetic , assignment , attributes , calculus , combinatorial , compilation ,
21- comparison , control , datentime , diffeqns , evaluation , exptrig , functional ,
22- graphics , graphics3d ,
23- image , inout , integer , iohooks , linalg , lists , logic ,
24- manipulate , quantities , numbertheory , numeric , options , patterns ,
25- plot , physchemdata , randomnumbers , recurrence , specialfunctions , scoping ,
26- strings , structure , system , tensors , xmlformat , optimization ]
61+ algebra ,
62+ arithmetic ,
63+ assignment ,
64+ attributes ,
65+ calculus ,
66+ combinatorial ,
67+ compilation ,
68+ comparison ,
69+ constants ,
70+ control ,
71+ datentime ,
72+ diffeqns ,
73+ evaluation ,
74+ exptrig ,
75+ functional ,
76+ graphics ,
77+ graphics3d ,
78+ image ,
79+ inout ,
80+ integer ,
81+ iohooks ,
82+ linalg ,
83+ lists ,
84+ logic ,
85+ manipulate ,
86+ quantities ,
87+ numbertheory ,
88+ numeric ,
89+ options ,
90+ patterns ,
91+ plot ,
92+ physchemdata ,
93+ randomnumbers ,
94+ recurrence ,
95+ specialfunctions ,
96+ scoping ,
97+ strings ,
98+ structure ,
99+ system ,
100+ tensors ,
101+ xmlformat ,
102+ optimization ,
103+ ]
27104
28105if ENABLE_FILES_MODULE :
29106 from mathics .builtin import files , importexport
107+
30108 modules += [files , importexport ]
31109
32110builtins = []
36114def is_builtin (var ):
37115 if var == Builtin :
38116 return True
39- if hasattr (var , ' __bases__' ):
117+ if hasattr (var , " __bases__" ):
40118 return any (is_builtin (base ) for base in var .__bases__ )
41119 return False
42120
@@ -46,11 +124,14 @@ def is_builtin(var):
46124 vars = dir (module )
47125 for name in vars :
48126 var = getattr (module , name )
49- if (hasattr (var , '__module__' ) and
50- var .__module__ .startswith ('mathics.builtin.' ) and
51- var .__module__ != 'mathics.builtin.base' and
52- is_builtin (var ) and not name .startswith ('_' ) and
53- var .__module__ == module .__name__ ): # nopep8
127+ if (
128+ hasattr (var , "__module__" )
129+ and var .__module__ .startswith ("mathics.builtin." )
130+ and var .__module__ != "mathics.builtin.base"
131+ and is_builtin (var )
132+ and not name .startswith ("_" )
133+ and var .__module__ == module .__name__
134+ ): # nopep8
54135
55136 instance = var (expression = False )
56137
@@ -61,8 +142,8 @@ def is_builtin(var):
61142
62143# builtins = dict(builtins)
63144
64- mathics_to_sympy = {} # here we have: name -> sympy object
65- mathics_to_python = {} # here we have: name -> string
145+ mathics_to_sympy = {} # here we have: name -> sympy object
146+ mathics_to_python = {} # here we have: name -> string
66147sympy_to_mathics = {}
67148
68149box_constructs = {}
@@ -101,22 +182,22 @@ def get_module_doc(module):
101182 doc = doc .strip ()
102183 if doc :
103184 title = doc .splitlines ()[0 ]
104- text = ' \n ' .join (doc .splitlines ()[1 :])
185+ text = " \n " .join (doc .splitlines ()[1 :])
105186 else :
106187 title = module .__name__
107- for prefix in (' mathics.builtin.' , ' mathics.optional.' ):
188+ for prefix in (" mathics.builtin." , " mathics.optional." ):
108189 if title .startswith (prefix ):
109- title = title [len (prefix ):]
190+ title = title [len (prefix ) :]
110191 title = title .capitalize ()
111- text = ''
192+ text = ""
112193 return title , text
113194
114195
115196def contribute (definitions ):
116197 # let MakeBoxes contribute first
117- builtins [' System`MakeBoxes' ].contribute (definitions )
198+ builtins [" System`MakeBoxes" ].contribute (definitions )
118199 for name , item in builtins .items ():
119- if name != ' System`MakeBoxes' :
200+ if name != " System`MakeBoxes" :
120201 item .contribute (definitions )
121202
122203 from mathics .core .expression import ensure_context
0 commit comments