Skip to content

Commit e6fd035

Browse files
committed
Add more builtin modules
1 parent de755aa commit e6fd035

14 files changed

Lines changed: 34 additions & 35 deletions

File tree

mathics/builtin/combinatorial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from mathics.builtin.base import Builtin
1111
from mathics.core.expression import Expression, Integer, Symbol, SymbolTrue, SymbolFalse
12-
from mathics.builtin.numbers.arithmetic import _MPMathFunction
12+
from mathics.builtin.arithmetic import _MPMathFunction
1313
from itertools import combinations
1414

1515

mathics/builtin/drawing/graphics3d.py

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,

mathics/builtin/drawing/image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1294,7 +1294,7 @@ def apply(self, input, colorspace, evaluation):
12941294
if isinstance(input, Image):
12951295
return input.color_convert(colorspace.get_string_value())
12961296
else:
1297-
from mathics.builtin.drawing.graphics import (
1297+
from mathics.builtin.graphics import (
12981298
expression_to_color,
12991299
color_to_expression,
13001300
)

mathics/builtin/drawing/plot.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
)
2727

2828
from mathics.builtin.base import Builtin
29-
from mathics.builtin.drawing.graphics import Graphics
29+
from mathics.builtin.graphics import Graphics
3030
from mathics.builtin.drawing.graphics3d import Graphics3D
3131
from mathics.builtin.numbers.numeric import chop
3232
from mathics.builtin.options import options_to_rules
@@ -40,7 +40,6 @@
4040
except ImportError:
4141
has_compile = False
4242

43-
4443
def gradient_palette(color_function, n, evaluation): # always returns RGB values
4544
if isinstance(color_function, String):
4645
color_data = Expression("ColorData", color_function).evaluate(evaluation)
@@ -65,7 +64,7 @@ def gradient_palette(color_function, n, evaluation): # always returns RGB value
6564
if len(colors.leaves) != n:
6665
return
6766

68-
from mathics.builtin.drawing.graphics import expression_to_color, ColorError
67+
from mathics.builtin.graphics import expression_to_color, ColorError
6968

7069
try:
7170
objects = [expression_to_color(x) for x in colors.leaves]
@@ -341,7 +340,6 @@ def get_plot_range(values, all_values, option):
341340

342341

343342
class _Plot(Builtin):
344-
from .graphics import Graphics
345343

346344
attributes = ("HoldAll",)
347345

@@ -706,8 +704,6 @@ def find_excl(excl):
706704
class _Chart(Builtin):
707705
attributes = ("HoldAll",)
708706

709-
from .graphics import Graphics
710-
711707
options = Graphics.options.copy()
712708
options.update(
713709
{
@@ -1136,8 +1132,6 @@ class Histogram(Builtin):
11361132
= -Graphics-
11371133
"""
11381134

1139-
from .graphics import Graphics
1140-
11411135
attributes = ("HoldAll",)
11421136

11431137
options = Graphics.options.copy()
@@ -2225,8 +2219,6 @@ class ListPlot(_ListPlot):
22252219
= -Graphics-
22262220
"""
22272221

2228-
from .graphics import Graphics
2229-
22302222
attributes = ("HoldAll",)
22312223

22322224
options = Graphics.options.copy()
@@ -2265,8 +2257,6 @@ class ListLinePlot(_ListPlot):
22652257
= -Graphics-
22662258
"""
22672259

2268-
from .graphics import Graphics
2269-
22702260
attributes = ("HoldAll",)
22712261

22722262
options = Graphics.options.copy()
@@ -2345,8 +2335,6 @@ class Plot3D(_Plot3D):
23452335
#> Plot3D[x + 2y, {x, -2, 2}, {y, -2, 2}] // TeXForm
23462336
"""
23472337

2348-
from .graphics import Graphics
2349-
23502338
attributes = ("HoldAll",)
23512339

23522340
options = Graphics.options.copy()
@@ -2429,8 +2417,6 @@ class DensityPlot(_Plot3D):
24292417
= -Graphics-
24302418
"""
24312419

2432-
from .graphics import Graphics
2433-
24342420
attributes = ("HoldAll",)
24352421

24362422
options = Graphics.options.copy()
Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
SymbolList,
3030
SymbolN,
3131
SymbolMakeBoxes,
32-
strip_context,
3332
system_symbols,
3433
system_symbols_dict,
3534
from_python,
@@ -119,7 +118,9 @@ def cut(value):
119118
return value
120119

121120

122-
def create_css(edge_color=None, face_color=None, stroke_width=None, font_color=None, opacity=1.0):
121+
def create_css(
122+
edge_color=None, face_color=None, stroke_width=None, font_color=None, opacity=1.0
123+
):
123124
css = []
124125
if edge_color is not None:
125126
color, stroke_opacity = edge_color.to_css()
@@ -1004,7 +1005,7 @@ def distance(a, b):
10041005
else:
10051006
return Expression(
10061007
"List",
1007-
*[distance(a, b) for a, b in zip(c1.leaves, c2.leaves)]
1008+
*[distance(a, b) for a, b in zip(c1.leaves, c2.leaves)],
10081009
)
10091010
else:
10101011
return Expression(SymbolList, *[distance(c, c2) for c in c1.leaves])
@@ -1805,7 +1806,7 @@ def parse_component(segments):
18051806
k = spline_degree.get_int_value()
18061807
elif head == "System`BSplineCurve":
18071808
raise NotImplementedError # FIXME convert bspline to bezier here
1808-
parts = segment.leaves
1809+
# parts = segment.leaves
18091810
else:
18101811
raise BoxConstructError
18111812

@@ -2569,7 +2570,16 @@ def default_arrow(px, py, vx, vy, t1, s):
25692570

25702571

25712572
class InsetBox(_GraphicsElement):
2572-
def init(self, graphics, style, item=None, content=None, pos=None, opos=(0, 0), opacity=1.0):
2573+
def init(
2574+
self,
2575+
graphics,
2576+
style,
2577+
item=None,
2578+
content=None,
2579+
pos=None,
2580+
opos=(0, 0),
2581+
opacity=1.0,
2582+
):
25732583
super(InsetBox, self).init(graphics, item, style)
25742584

25752585
self.color = self.style.get_option("System`FontColor")
@@ -2618,15 +2628,16 @@ def to_svg(self, offset=None):
26182628
svg = "\n" + content + "\n"
26192629
else:
26202630
css_style = create_css(
2621-
font_color=self.color, edge_color=self.color, face_color=self.color, opacity=self.opacity
2631+
font_color=self.color,
2632+
edge_color=self.color,
2633+
face_color=self.color,
2634+
opacity=self.opacity,
26222635
)
26232636
text_pos_opts = f'x="{x}" y="{y}" ox="{self.opos[0]}" oy="{self.opos[1]}"'
26242637
# FIXME: don't hard code text_style_opts, but allow these to be adjustable.
26252638
text_style_opts = "text-anchor:middle; dominant-baseline:middle;"
26262639
content = self.content.boxes_to_text(evaluation=self.graphics.evaluation)
2627-
svg = (
2628-
f'<text {text_pos_opts} style="{text_style_opts} {css_style}">{content}</text>'
2629-
)
2640+
svg = f'<text {text_pos_opts} style="{text_style_opts} {css_style}">{content}</text>'
26302641

26312642
# content = self.content.boxes_to_mathml(evaluation=self.graphics.evaluation)
26322643
# style = create_css(font_color=self.color)

mathics/builtin/numbers/exptrig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
)
2323

2424
from mathics.builtin.numbers.numeric import Fold
25-
from mathics.builtin.numbers.arithmetic import _MPMathFunction
25+
from mathics.builtin.arithmetic import _MPMathFunction
2626

2727

2828
class AnglePath(Builtin):

mathics/builtin/specialfns/bessel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from mathics.version import __version__ # noqa used in loading to check consistency.
99

10-
from mathics.builtin.numbers.arithmetic import _MPMathFunction
10+
from mathics.builtin.arithmetic import _MPMathFunction
1111
from mathics.builtin.base import Builtin
1212
from mathics.core.expression import from_mpmath
1313
from mathics.core.numbers import machine_precision, get_precision, PrecisionValueError

mathics/builtin/specialfns/erf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from mathics.version import __version__ # noqa used in loading to check consistency.
88

9-
from mathics.builtin.numbers.arithmetic import _MPMathFunction, _MPMathMultiFunction
9+
from mathics.builtin.arithmetic import _MPMathFunction, _MPMathMultiFunction
1010

1111
class Erf(_MPMathMultiFunction):
1212
"""

0 commit comments

Comments
 (0)