Skip to content

Commit f2597b9

Browse files
authored
Merge pull request #1321 from mathics/builtin-submodules
Builtin submodules
2 parents 639f03f + 68f24bd commit f2597b9

28 files changed

Lines changed: 75 additions & 56 deletions

mathics/builtin/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def is_builtin(var):
130130
_builtins = []
131131
builtins_by_module = {}
132132

133-
for subdir in ("specialfns",):
133+
for subdir in ("drawing", "numbers", "specialfns",):
134134
import_name = f"{__name__}.{subdir}"
135135
builtin_module = importlib.import_module(import_name)
136136
submodule_names = [

mathics/builtin/assignment.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,11 +1922,11 @@ class LoadModule(Builtin):
19221922
def apply(self, module, evaluation):
19231923
"LoadModule[module_String]"
19241924
try:
1925-
module_loaded = evaluation.definitions.load_pymathics_module(module.value)
1926-
except PyMathicsLoadException as e:
1925+
evaluation.definitions.load_pymathics_module(module.value)
1926+
except PyMathicsLoadException:
19271927
evaluation.message(self.name, "notmathicslib", module)
19281928
return SymbolFailed
1929-
except ImportError as e:
1929+
except ImportError:
19301930
evaluation.message(self.get_name(), "notfound", module)
19311931
return SymbolFailed
19321932
else:

mathics/builtin/comparison.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
SympyFunction,
1414
)
1515

16-
from mathics.builtin.constants import mp_convert_constant
16+
from mathics.builtin.numbers.constants import mp_convert_constant
1717

1818
from mathics.core.expression import (
1919
COMPARE_PREC,
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""
2+
Graphics, Drawing, and Images
3+
"""
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
SymbolList,
1515
)
1616
from mathics.builtin.base import BoxConstructError, Builtin, InstanceableBuiltin
17-
from .graphics import (
17+
from mathics.builtin.graphics import (
1818
Graphics,
1919
GraphicsBox,
2020
PolygonBox,
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
SymbolRule,
2222
from_python,
2323
)
24-
from mathics.builtin.colors import (
24+
from mathics.builtin.drawing.colors import (
2525
convert as convert_color,
2626
colorspaces as known_colorspaces,
2727
)
@@ -1599,7 +1599,7 @@ def apply(self, values, evaluation, options):
15991599
):
16001600
color_function = String("LakeColors")
16011601

1602-
from mathics.builtin.plot import gradient_palette
1602+
from mathics.builtin.drawing.plot import gradient_palette
16031603

16041604
cmap = gradient_palette(color_function, n, evaluation)
16051605
if not cmap:
Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@
2424
SymbolN,
2525
SymbolRule,
2626
)
27+
2728
from mathics.builtin.base import Builtin
28-
from mathics.builtin.scoping import dynamic_scoping
29-
from mathics.builtin.options import options_to_rules
30-
from mathics.builtin.numeric import chop
3129
from mathics.builtin.graphics import Graphics
32-
from mathics.builtin.graphics3d import Graphics3D
30+
from mathics.builtin.drawing.graphics3d import Graphics3D
31+
from mathics.builtin.numeric import chop
32+
from mathics.builtin.options import options_to_rules
33+
from mathics.builtin.scoping import dynamic_scoping
3334

3435

3536
try:
@@ -39,7 +40,6 @@
3940
except ImportError:
4041
has_compile = False
4142

42-
4343
def gradient_palette(color_function, n, evaluation): # always returns RGB values
4444
if isinstance(color_function, String):
4545
color_data = Expression("ColorData", color_function).evaluate(evaluation)
@@ -340,7 +340,6 @@ def get_plot_range(values, all_values, option):
340340

341341

342342
class _Plot(Builtin):
343-
from .graphics import Graphics
344343

345344
attributes = ("HoldAll",)
346345

@@ -705,8 +704,6 @@ def find_excl(excl):
705704
class _Chart(Builtin):
706705
attributes = ("HoldAll",)
707706

708-
from .graphics import Graphics
709-
710707
options = Graphics.options.copy()
711708
options.update(
712709
{
@@ -1135,8 +1132,6 @@ class Histogram(Builtin):
11351132
= -Graphics-
11361133
"""
11371134

1138-
from .graphics import Graphics
1139-
11401135
attributes = ("HoldAll",)
11411136

11421137
options = Graphics.options.copy()
@@ -2224,8 +2219,6 @@ class ListPlot(_ListPlot):
22242219
= -Graphics-
22252220
"""
22262221

2227-
from .graphics import Graphics
2228-
22292222
attributes = ("HoldAll",)
22302223

22312224
options = Graphics.options.copy()
@@ -2264,8 +2257,6 @@ class ListLinePlot(_ListPlot):
22642257
= -Graphics-
22652258
"""
22662259

2267-
from .graphics import Graphics
2268-
22692260
attributes = ("HoldAll",)
22702261

22712262
options = Graphics.options.copy()
@@ -2344,8 +2335,6 @@ class Plot3D(_Plot3D):
23442335
#> Plot3D[x + 2y, {x, -2, 2}, {y, -2, 2}] // TeXForm
23452336
"""
23462337

2347-
from .graphics import Graphics
2348-
23492338
attributes = ("HoldAll",)
23502339

23512340
options = Graphics.options.copy()
@@ -2428,8 +2417,6 @@ class DensityPlot(_Plot3D):
24282417
= -Graphics-
24292418
"""
24302419

2431-
from .graphics import Graphics
2432-
24332420
attributes = ("HoldAll",)
24342421

24352422
options = Graphics.options.copy()

mathics/builtin/files.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
String,
3636
Symbol,
3737
SymbolFailed,
38-
SymbolFalse,
3938
SymbolNull,
4039
SymbolTrue,
4140
from_mpmath,
@@ -46,10 +45,8 @@
4645
Stream,
4746
path_search,
4847
stream_manager,
49-
urlsave_tmp,
5048
)
5149
from mathics.builtin.base import Builtin, Predefined, BinaryOperator, PrefixOperator
52-
from mathics.builtin.numeric import Hash
5350
from mathics.builtin.strings import to_python_encoding
5451
from mathics.builtin.base import MessageException
5552

0 commit comments

Comments
 (0)