diff --git a/mathics/builtin/base.py b/mathics/builtin/base.py
index ac3f1e1b7..4a21365a2 100644
--- a/mathics/builtin/base.py
+++ b/mathics/builtin/base.py
@@ -238,7 +238,6 @@ def eval_with_options(x, evaluation: Evaluation, options: dict):
name: Optional[str] = None
context: str = ""
- abstract: bool = False
attributes: int = A_PROTECTED
is_numeric: bool = False
rules: Dict[str, Any] = {}
diff --git a/mathics/builtin/datentime.py b/mathics/builtin/datentime.py
index 9221c3b4f..0ff8f0e38 100644
--- a/mathics/builtin/datentime.py
+++ b/mathics/builtin/datentime.py
@@ -5,7 +5,8 @@
Dates and times are represented symbolically; computations can be performed on them.
-Date object can also input and output dates and times in a wide range of formats, as well as handle calendars.
+Date object can also input and output dates and times in a wide range of formats, as \
+well as handle calendars.
"""
import re
@@ -259,7 +260,6 @@ def to_datelist(self, epochtime, evaluation):
(isinstance(val, float) and i > 1) or isinstance(val, int)
for i, val in enumerate(etime)
):
-
default_date = [1900, 1, 1, 0, 0, 0.0]
datelist = etime + default_date[len(etime) :]
prec_part, imprec_part = datelist[:2], datelist[2:]
@@ -348,7 +348,8 @@ class AbsoluteTime(_DateFormat):
- 'AbsoluteTime[]'
-
- gives the local time in seconds since epoch January 1, 1900, in your time zone.
+
- gives the local time in seconds since epoch January 1, 1900, in your \
+ time zone.
- 'AbsoluteTime[{$y$, $m$, $d$, $h$, $m$, $s$}]'
- gives the absolute time specification corresponding to a date list.
@@ -380,9 +381,7 @@ class AbsoluteTime(_DateFormat):
= 1000
"""
- abstract = "absolute time in seconds"
-
- summary_text = "absolute time in seconds"
+ summary_text = "get absolute time in seconds"
def eval_now(self, evaluation):
"AbsoluteTime[]"
@@ -410,7 +409,8 @@ class AbsoluteTiming(Builtin):
- 'AbsoluteTiming[$expr$]'
-
- evaluates $expr$, returning a list of the absolute number of seconds in real time that have elapsed, together with the result obtained.
+
- evaluates $expr$, returning a list of the absolute number of seconds in \
+ real time that have elapsed, together with the result obtained.
>> AbsoluteTiming[50!]
@@ -421,7 +421,7 @@ class AbsoluteTiming(Builtin):
attributes = A_HOLD_ALL | A_PROTECTED
- summary_text = "total wall-clock time to run a Mathics command"
+ summary_text = "get total wall-clock time to run a Mathics command"
def eval(self, expr, evaluation):
"AbsoluteTiming[expr_]"
@@ -612,7 +612,9 @@ class DateObject(_DateFormat, ImmutableValueMixin):
]
messages = {
- "notz": "Argument `1` in DateObject is not a recognized TimeZone specification.",
+ "notz": (
+ "Argument `1` in DateObject is not a recognized " "TimeZone specification."
+ ),
}
options = {
@@ -625,9 +627,7 @@ class DateObject(_DateFormat, ImmutableValueMixin):
"DateObject[]": "DateObject[AbsoluteTime[]]",
}
- summary_text = (
- " an object representing a date of any granularity (year, hour, instant, ...)"
- )
+ summary_text = "get an object representing a date (year, hour, instant, ...)"
def eval_any(self, args, evaluation: Evaluation, options: dict):
"DateObject[args_, OptionsPattern[]]"
@@ -779,7 +779,6 @@ def eval(self, date, off, evaluation):
and isinstance(o[0], (float, int))
for o in pyoff
):
-
for o in pyoff:
idate.addself([o[0] * TIME_INCREMENTS[o[1]][i] for i in range(6)])
else:
@@ -998,7 +997,7 @@ class DateStringFormat(Predefined):
value = "DateTimeShort"
- summary_text = "default date string format"
+ summary_text = "get default date string format as a list"
# TODO: Methods to change this
@@ -1091,7 +1090,8 @@ class SystemTimeZone(Predefined):
- '$SystemTimeZone'
-
- gives the current time zone for the computer system on which Mathics is being run.
+
- gives the current time zone for the computer system on which Mathics is \
+ being run.
>> $SystemTimeZone
@@ -1101,7 +1101,7 @@ class SystemTimeZone(Predefined):
name = "$SystemTimeZone"
value = Real(-time.timezone / 3600.0)
- summary_text = "time zone used by your system"
+ summary_text = "get the time zone used by your system"
def evaluate(self, evaluation):
return self.value
@@ -1120,7 +1120,7 @@ class Now(Predefined):
= ...
"""
- summary_text = "current date and time"
+ summary_text = "get current date and time"
def evaluate(self, evaluation):
return Expression(SymbolDateObject.evaluate(evaluation))
@@ -1142,9 +1142,9 @@ class TimeConstrained(Builtin):
Possible issues: for certain time-consuming functions (like simplify)
which are based on sympy or other libraries, it is possible that
- the evaluation continues after the timeout. However, at the end of the evaluation, the function will return '$Aborted' and the results will not affect
- the state of the \\Mathics kernel.
-
+ the evaluation continues after the timeout. However, at the end of the \
+ evaluation, the function will return '$Aborted' and the results will not affect
+ the state of the Mathics3 kernel.
"""
# FIXME: these tests sometimes cause SEGVs which probably means
@@ -1166,7 +1166,10 @@ class TimeConstrained(Builtin):
attributes = A_HOLD_ALL | A_PROTECTED
messages = {
- "timc": "Number of seconds `1` is not a positive machine-sized number or Infinity.",
+ "timc": (
+ "Number of seconds `1` is not a positive machine-sized number "
+ "or Infinity."
+ ),
}
summary_text = "run a command for at most a specified time"
@@ -1219,7 +1222,7 @@ class TimeZone(Predefined):
"$TimeZone": str(value),
}
- summary_text = "resettable default time zone"
+ summary_text = "gets the default time zone"
def eval(self, lhs, rhs, evaluation):
"lhs_ = rhs_"
@@ -1245,7 +1248,7 @@ class TimeUsed(Builtin):
"""
summary_text = (
- "the total number of seconds of CPU time in the current Mathics session"
+ "get the total number of seconds of CPU time in the current Mathics3 session"
)
def eval(self, evaluation):
@@ -1274,7 +1277,7 @@ class Timing(Builtin):
attributes = A_HOLD_ALL | A_PROTECTED
- summary_text = "CPU time to run a Mathics command"
+ summary_text = "get CPU time to run a Mathics3 command"
def eval(self, expr, evaluation):
"Timing[expr_]"
@@ -1301,7 +1304,7 @@ class SessionTime(Builtin):
"""
summary_text = (
- "total elapsed time in seconds since the beginning of your Mathics session"
+ "get total elapsed time in seconds since the beginning of Mathics3 session"
)
def eval(self, evaluation):
@@ -1317,7 +1320,8 @@ class TimeRemaining(Builtin):
- 'TimeRemaining[]'
-
- Gives the number of seconds remaining until the earliest enclosing 'TimeConstrained' will request the current computation to stop.
+
- Gives the number of seconds remaining until the earliest enclosing \
+ 'TimeConstrained' will request the current computation to stop.
- 'TimeConstrained[$expr$, $t$, $failexpr$]'
- returns $failexpr$ if the time constraint is not met.
@@ -1332,7 +1336,7 @@ class TimeRemaining(Builtin):
"""
- summary_text = "time before a time constraint in a running program"
+ summary_text = "get remaining time in allowed to run an expression"
def eval(self, evaluation):
"TimeRemaining[]"
diff --git a/mathics/builtin/drawing/__init__.py b/mathics/builtin/drawing/__init__.py
index eec632ffb..ce5e3a26e 100644
--- a/mathics/builtin/drawing/__init__.py
+++ b/mathics/builtin/drawing/__init__.py
@@ -4,19 +4,21 @@
Showing something visually can be done in a number of ways:
- - Starting with complete images and modifying them using the 'Image' Built-in function.
+
- Starting with complete images and modifying them using the 'Image' \
+ Built-in function.
- Use pre-defined 2D or 3D objects like
:'Circle':
/doc/reference-of-built-in-symbols/drawing-graphics/circle and
:'Cuboid':
- /doc/reference-of-built-in-symbols/graphics-drawing-and-images/three-dimensional-graphics/cuboid/ \
+/doc/reference-of-built-in-symbols/graphics-and-drawing/three-dimensional-graphics/cuboid/ \
and place them in a coordinate space.
-
- Compute the points of the space using a function. This is done using functions like
+
- Compute the points of the space using a function. This is done using functions \
+ like
:'Plot':
- /doc/reference-of-built-in-symbols/graphics-drawing-and-images/plotting-data/plot \
+ /doc/reference-of-built-in-symbols/graphics-and-drawing/plotting-data/plot
\
and
:'ListPlot':
- /doc/reference-of-built-in-symbols/graphics-drawing-and-images/plotting-data/listplot.
+ /doc/reference-of-built-in-symbols/graphics-and-drawing/plotting-data/listplot.
"""
diff --git a/mathics/builtin/drawing/graphics3d.py b/mathics/builtin/drawing/graphics3d.py
index 38ef5db56..5244b6dda 100644
--- a/mathics/builtin/drawing/graphics3d.py
+++ b/mathics/builtin/drawing/graphics3d.py
@@ -63,66 +63,68 @@ def get_default_face_color(self):
class Graphics3D(Graphics):
r"""
- :WMA link:https://reference.wolfram.com/language/ref/Graphics3D.html
-
-
- - 'Graphics3D[$primitives$, $options$]'
-
- represents a three-dimensional graphic.
-
-
- See also the Section "Plotting" for a list of Plot options.
-
-
- >> Graphics3D[Polygon[{{0,0,0}, {0,1,1}, {1,0,0}}]]
- = -Graphics3D-
-
- In 'TeXForm', 'Graphics3D' creates Asymptote figures:
- >> Graphics3D[Sphere[]] // TeXForm
- = #<--#
- . \begin{asy}
- . import three;
- . import solids;
- . size(6.6667cm, 6.6667cm);
- . currentprojection=perspective(2.6,-4.8,4.0);
- . currentlight=light(rgb(0.5,0.5,1), specular=red, (2,0,2), (2,2,2), (0,2,2));
- . // Sphere3DBox
- . draw(surface(sphere((0, 0, 0), 1)), rgb(1,1,1)+opacity(1));
- . draw(((-1,-1,-1)--(1,-1,-1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
- . draw(((-1,1,-1)--(1,1,-1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
- . draw(((-1,-1,1)--(1,-1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
- . draw(((-1,1,1)--(1,1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
- . draw(((-1,-1,-1)--(-1,1,-1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
- . draw(((1,-1,-1)--(1,1,-1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
- . draw(((-1,-1,1)--(-1,1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
- . draw(((1,-1,1)--(1,1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
- . draw(((-1,-1,-1)--(-1,-1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
- . draw(((1,-1,-1)--(1,-1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
- . draw(((-1,1,-1)--(-1,1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
- . draw(((1,1,-1)--(1,1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
- . \end{asy}
-
- #> Graphics3D[Point[Table[{Sin[t], Cos[t], 0}, {t, 0, 2. Pi, Pi / 15.}]]] // TeXForm
- = #<--#
- . \begin{asy}
- . import three;
- . import solids;
- . size(6.6667cm, 6.6667cm);
- . currentprojection=perspective(2.6,-4.8,4.0);
- . currentlight=light(rgb(0.5,0.5,1), specular=red, (2,0,2), (2,2,2), (0,2,2));
- . // Point3DBox
- . path3 g=(0,1,0)--(0.20791,0.97815,0)--(0.40674,0.91355,0)--(0.58779,0.80902,0)--(0.74314,0.66913,0)--(0.86603,0.5,0)--(0.95106,0.30902,0)--(0.99452,0.10453,0)--(0.99452,-0.10453,0)--(0.95106,-0.30902,0)--(0.86603,-0.5,0)--(0.74314,-0.66913,0)--(0.58779,-0.80902,0)--(0.40674,-0.91355,0)--(0.20791,-0.97815,0)--(5.6655e-16,-1,0)--(-0.20791,-0.97815,0)--(-0.40674,-0.91355,0)--(-0.58779,-0.80902,0)--(-0.74314,-0.66913,0)--(-0.86603,-0.5,0)--(-0.95106,-0.30902,0)--(-0.99452,-0.10453,0)--(-0.99452,0.10453,0)--(-0.95106,0.30902,0)--(-0.86603,0.5,0)--(-0.74314,0.66913,0)--(-0.58779,0.80902,0)--(-0.40674,0.91355,0)--(-0.20791,0.97815,0)--(1.5314e-15,1,0)--cycle;dot(g, rgb(0, 0, 0));
- . draw(((-0.99452,-1,-1)--(0.99452,-1,-1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
- . draw(((-0.99452,1,-1)--(0.99452,1,-1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
- . draw(((-0.99452,-1,1)--(0.99452,-1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
- . draw(((-0.99452,1,1)--(0.99452,1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
- . draw(((-0.99452,-1,-1)--(-0.99452,1,-1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
- . draw(((0.99452,-1,-1)--(0.99452,1,-1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
- . draw(((-0.99452,-1,1)--(-0.99452,1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
- . draw(((0.99452,-1,1)--(0.99452,1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
- . draw(((-0.99452,-1,-1)--(-0.99452,-1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
- . draw(((0.99452,-1,-1)--(0.99452,-1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
- . draw(((-0.99452,1,-1)--(-0.99452,1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
- . draw(((0.99452,1,-1)--(0.99452,1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
- . \end{asy}
+ :WMA link:https://reference.wolfram.com/language/ref/Graphics3D.html
+
+
+ - 'Graphics3D[$primitives$, $options$]'
+
- represents a three-dimensional graphic.
+
+ See also the :Drawing Option and Option Values:
+ /doc/reference-of-built-in-symbols/drawing-options-and-option-values
+ for a list of Plot options.
+
+
+ >> Graphics3D[Polygon[{{0,0,0}, {0,1,1}, {1,0,0}}]]
+ = -Graphics3D-
+
+ In 'TeXForm', 'Graphics3D' creates Asymptote figures:
+ >> Graphics3D[Sphere[]] // TeXForm
+ = #<--#
+ . \begin{asy}
+ . import three;
+ . import solids;
+ . size(6.6667cm, 6.6667cm);
+ . currentprojection=perspective(2.6,-4.8,4.0);
+ . currentlight=light(rgb(0.5,0.5,1), specular=red, (2,0,2), (2,2,2), (0,2,2));
+ . // Sphere3DBox
+ . draw(surface(sphere((0, 0, 0), 1)), rgb(1,1,1)+opacity(1));
+ . draw(((-1,-1,-1)--(1,-1,-1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
+ . draw(((-1,1,-1)--(1,1,-1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
+ . draw(((-1,-1,1)--(1,-1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
+ . draw(((-1,1,1)--(1,1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
+ . draw(((-1,-1,-1)--(-1,1,-1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
+ . draw(((1,-1,-1)--(1,1,-1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
+ . draw(((-1,-1,1)--(-1,1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
+ . draw(((1,-1,1)--(1,1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
+ . draw(((-1,-1,-1)--(-1,-1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
+ . draw(((1,-1,-1)--(1,-1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
+ . draw(((-1,1,-1)--(-1,1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
+ . draw(((1,1,-1)--(1,1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
+ . \end{asy}
+
+ #> Graphics3D[Point[Table[{Sin[t], Cos[t], 0}, {t, 0, 2. Pi, Pi / 15.}]]] // TeXForm
+ = #<--#
+ . \begin{asy}
+ . import three;
+ . import solids;
+ . size(6.6667cm, 6.6667cm);
+ . currentprojection=perspective(2.6,-4.8,4.0);
+ . currentlight=light(rgb(0.5,0.5,1), specular=red, (2,0,2), (2,2,2), (0,2,2));
+ . // Point3DBox
+ . path3 g=(0,1,0)--(0.20791,0.97815,0)--(0.40674,0.91355,0)--(0.58779,0.80902,0)--(0.74314,0.66913,0)--(0.86603,0.5,0)--(0.95106,0.30902,0)--(0.99452,0.10453,0)--(0.99452,-0.10453,0)--(0.95106,-0.30902,0)--(0.86603,-0.5,0)--(0.74314,-0.66913,0)--(0.58779,-0.80902,0)--(0.40674,-0.91355,0)--(0.20791,-0.97815,0)--(5.6655e-16,-1,0)--(-0.20791,-0.97815,0)--(-0.40674,-0.91355,0)--(-0.58779,-0.80902,0)--(-0.74314,-0.66913,0)--(-0.86603,-0.5,0)--(-0.95106,-0.30902,0)--(-0.99452,-0.10453,0)--(-0.99452,0.10453,0)--(-0.95106,0.30902,0)--(-0.86603,0.5,0)--(-0.74314,0.66913,0)--(-0.58779,0.80902,0)--(-0.40674,0.91355,0)--(-0.20791,0.97815,0)--(1.5314e-15,1,0)--cycle;dot(g, rgb(0, 0, 0));
+ . draw(((-0.99452,-1,-1)--(0.99452,-1,-1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
+ . draw(((-0.99452,1,-1)--(0.99452,1,-1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
+ . draw(((-0.99452,-1,1)--(0.99452,-1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
+ . draw(((-0.99452,1,1)--(0.99452,1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
+ . draw(((-0.99452,-1,-1)--(-0.99452,1,-1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
+ . draw(((0.99452,-1,-1)--(0.99452,1,-1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
+ . draw(((-0.99452,-1,1)--(-0.99452,1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
+ . draw(((0.99452,-1,1)--(0.99452,1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
+ . draw(((-0.99452,-1,-1)--(-0.99452,-1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
+ . draw(((0.99452,-1,-1)--(0.99452,-1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
+ . draw(((-0.99452,1,-1)--(-0.99452,1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
+ . draw(((0.99452,1,-1)--(0.99452,1,1)), rgb(0.4, 0.4, 0.4)+linewidth(1));
+ . \end{asy}
"""
summary_text = "a three-dimensional graphics image wrapper"
options = Graphics.options.copy()
diff --git a/mathics/builtin/drawing/plot.py b/mathics/builtin/drawing/plot.py
index 7c5421da4..d641cfa06 100644
--- a/mathics/builtin/drawing/plot.py
+++ b/mathics/builtin/drawing/plot.py
@@ -1539,7 +1539,7 @@ class DiscretePlot(_Plot):
= -Graphics-
Compare with :'Plot':
- /doc/reference-of-built-in-symbols/graphics-drawing-and-images/plotting-data/plot/.
+ /doc/reference-of-built-in-symbols/graphics-and-drawing/plotting-data/plot/.
"""
attributes = A_HOLD_ALL | A_PROTECTED
@@ -1969,13 +1969,13 @@ class ListPlot(_ListPlot):
= -Graphics-
Compare with :'Plot':
- /doc/reference-of-built-in-symbols/graphics-drawing-and-images/plotting-data/plot/.
+ /doc/reference-of-built-in-symbols/graphics-and-drawing/plotting-data/plot/.
>> ListPlot[Table[n ^ 2, {n, 30}], Filling->Axis]
= -Graphics-
Compare with :'Plot':
- /doc/reference-of-built-in-symbols/graphics-drawing-and-images/plotting-data/plot.
+ /doc/reference-of-built-in-symbols/graphics-and-drawing/plotting-data/plot.
"""
options = Graphics.options.copy()
@@ -2560,15 +2560,24 @@ class Plot3D(_Plot3D):
:WMA link: https://reference.wolfram.com/language/ref/Plot3D.html
- 'Plot3D[$f$, {$x$, $xmin$, $xmax$}, {$y$, $ymin$, $ymax$}]'
-
- creates a three-dimensional plot of $f$ with $x$ ranging from $xmin$ to $xmax$ and $y$ ranging from $ymin$ to $ymax$.
+
- creates a three-dimensional plot of $f$ with $x$ ranging from $xmin$ to \
+ $xmax$ and $y$ ranging from $ymin$ to $ymax$.
- Plot3D has the same options as Graphics3D, in particular:
+ Plot3D has the same options as :Graphics3D:
+/doc/reference-of-built-in-symbols/graphics-and-drawing/three-dimensional-graphics/graphics3d,\
+ in particular:
- - Mesh
-
- PlotPoints
-
- MaxRecursion
+
-
+ :Mesh:
+ /doc/reference-of-built-in-symbols/drawing-options-and-option-values/mesh
+
-
+ :PlotPoints:
+ /doc/reference-of-built-in-symbols/drawing-options-and-option-values/plotpoints
+
-
+ :MaxRecursion:
+ /doc/reference-of-built-in-symbols/drawing-options-and-option-values/maxrecursion
diff --git a/mathics/builtin/exp_structure/general.py b/mathics/builtin/exp_structure/general.py
index 019a56bce..f2ae816a3 100644
--- a/mathics/builtin/exp_structure/general.py
+++ b/mathics/builtin/exp_structure/general.py
@@ -184,7 +184,7 @@ class Depth(Builtin):
= 2
"""
- summary_text = "the maximum number of indices to specify any part"
+ summary_text = "get maximum number of indices to specify any part"
def eval(self, expr, evaluation: Evaluation):
"Depth[expr_]"
@@ -295,7 +295,7 @@ class Level(Builtin):
options = {
"Heads": "False",
}
- summary_text = "parts specified by a given number of indices"
+ summary_text = "get parts specified by a given number of indices"
def eval(self, expr, ls, evaluation, options={}):
"Level[expr_, ls_, OptionsPattern[Level]]"
@@ -337,7 +337,7 @@ class Null(Predefined):
= #<--#
"""
- summary_text = "implicit result for expressions that does not yield a result"
+ summary_text = "implicit result for expressions that do not yield a result"
class Operate(Builtin):
@@ -417,7 +417,7 @@ class Order(Builtin):
- 'Order[$x$, $y$]'
- returns a number indicating the canonical ordering of $x$ and $y$. \
- 1 indicates that $x$ is before $y$, \-1 that $y$ is before $x$. \
+ 1 indicates that $x$ is before $y$, and -1 that $y$ is before $x$. \
0 indicates that there is no specific ordering. Uses the same order \
as 'Sort'.
@@ -435,7 +435,7 @@ class Order(Builtin):
= 0
"""
- summary_text = "canonical ordering of expressions"
+ summary_text = "order expressions"
def eval(self, x, y, evaluation: Evaluation):
"Order[x_, y_]"
diff --git a/mathics/builtin/exp_structure/size_and_sig.py b/mathics/builtin/exp_structure/size_and_sig.py
index 68b497dba..16b01e4e0 100644
--- a/mathics/builtin/exp_structure/size_and_sig.py
+++ b/mathics/builtin/exp_structure/size_and_sig.py
@@ -50,7 +50,7 @@ class ByteCount(Builtin):
The results may heavily depend on the Python implementation in use.
"""
- summary_text = "amount of memory used by expr, in bytes"
+ summary_text = "get the amount of memory used by expr, in bytes"
def eval(self, expression, evaluation: Evaluation):
"ByteCount[expression_]"
@@ -71,7 +71,8 @@ class Hash(Builtin):
- 'Hash[$expr$, $type$]'
- returns an integer hash of the specified $type$ for the given $expr$.
-
- The types supported are "MD5", "Adler32", "CRC32", "SHA", "SHA224", "SHA256", "SHA384", and "SHA512".
+
- The types supported are "MD5", "Adler32", "CRC32", "SHA", "SHA224", \
+ "SHA256", "SHA384", and "SHA512".
- 'Hash[$expr$, $type$, $format$]'
- Returns the hash in the specified format.
@@ -180,7 +181,7 @@ class LeafCount(Builtin):
messages = {
"argx": "LeafCount called with `1` arguments; 1 argument is expected.",
}
- summary_text = "the total number of atomic subexpressions"
+ summary_text = "get the total number of atomic subexpressions"
def eval(self, expr, evaluation: Evaluation):
"LeafCount[expr___]"
diff --git a/mathics/builtin/files_io/importexport.py b/mathics/builtin/files_io/importexport.py
index ad8353e06..1aa656f1d 100644
--- a/mathics/builtin/files_io/importexport.py
+++ b/mathics/builtin/files_io/importexport.py
@@ -10,17 +10,13 @@
:Export:
/doc/reference-of-built-in-symbols/importing-and-exporting/export, \
while
-:$InputFormats:
-/doc/reference-of-built-in-symbols/importing-and-exporting/$inputformats \
+:$ImportFormats:
+/doc/reference-of-built-in-symbols/importing-and-exporting/$importformats \
does the corresponding thing for
:Import:
/doc/reference-of-built-in-symbols/importing-and-exporting/import.
"""
-# This tells documentation how to sort this module
-# Here we are also hiding "file_io" since this can erroneously appear at the top level.
-sort_order = "mathics.builtin.importing-and-exporting"
-
import base64
import mimetypes
import os
@@ -47,6 +43,10 @@
SymbolToString,
)
+# This tells documentation how to sort this module
+# Here we are also hiding "file_io" since this can erroneously appear at the top level.
+sort_order = "mathics.builtin.importing-and-exporting"
+
mimetypes.add_type("application/vnd.wolfram.mathematica.package", ".m")
SymbolClose = Symbol("Close")
@@ -947,46 +947,6 @@ def _importer_exporter_options(
return stream_options, custom_options
-class ImportFormats(Predefined):
- """
- :WMA link:https://reference.wolfram.com/language/ref/$ImportFormats.html
-
-
- - '$ImportFormats'
-
- returns a list of file formats supported by Import.
-
-
- >> $ImportFormats
- = {...CSV,...JSON,...Text...}
- """
-
- name = "$ImportFormats"
- summary_text = "list supported import formats"
-
- def evaluate(self, evaluation: Evaluation):
- return to_mathics_list(*sorted(IMPORTERS.keys()), elements_conversion_fn=String)
-
-
-class ExportFormats(Predefined):
- """
- :WMA link:https://reference.wolfram.com/language/ref/$ExportFormats.html
-
-
- - '$ExportFormats'
-
- returns a list of file formats supported by Export.
-
-
- >> $ExportFormats
- = {...CSV,...SVG,...Text...}
- """
-
- name = "$ExportFormats"
- summary_text = "list supported export formats"
-
- def evaluate(self, evaluation: Evaluation):
- return to_mathics_list(*sorted(EXPORTERS.keys()), elements_conversion_fn=String)
-
-
class ConverterDumpsExtensionMappings(Predefined):
"""
## :internal native symbol:
@@ -1037,6 +997,46 @@ def evaluate(self, evaluation: Evaluation):
return from_python(FORMATMAPPINGS)
+class ExportFormats(Predefined):
+ """
+ :WMA link:https://reference.wolfram.com/language/ref/$ExportFormats.html
+
+
+ - '$ExportFormats'
+
- returns a list of file formats supported by Export.
+
+
+ >> $ExportFormats
+ = {...CSV,...SVG,...Text...}
+ """
+
+ name = "$ExportFormats"
+ summary_text = "list supported export formats"
+
+ def evaluate(self, evaluation: Evaluation):
+ return to_mathics_list(*sorted(EXPORTERS.keys()), elements_conversion_fn=String)
+
+
+class ImportFormats(Predefined):
+ """
+ :WMA link:https://reference.wolfram.com/language/ref/$ImportFormats.html
+
+
+ - '$ImportFormats'
+
- returns a list of file formats supported by Import.
+
+
+ >> $ImportFormats
+ = {...CSV,...JSON,...Text...}
+ """
+
+ name = "$ImportFormats"
+ summary_text = "list supported import formats"
+
+ def evaluate(self, evaluation: Evaluation):
+ return to_mathics_list(*sorted(IMPORTERS.keys()), elements_conversion_fn=String)
+
+
class RegisterImport(Builtin):
"""
## :internal native symbol:
@@ -1183,7 +1183,8 @@ class RegisterExport(Builtin):
- 'RegisterExport["$format$", $func$]'
-
- register '$func$' as the default function used when exporting from a file of type '"$format$"'.
+
- register '$func$' as the default function used when exporting from a file of \
+ type '"$format$"'.
Simple text exporter
@@ -1198,7 +1199,7 @@ class RegisterExport(Builtin):
#> DeleteFile["sample.txt"]
- Very basic encrypted text exporter
+ Very basic encrypted text exporter:
>> ExampleExporter2[filename_, data_, opts___] := Module[{strm = OpenWrite[filename], char}, (* TODO: Check data *) char = FromCharacterCode[Mod[ToCharacterCode[data] - 84, 26] + 97]; WriteString[strm, char]; Close[strm]]
>> ImportExport`RegisterExport["ExampleFormat2", ExampleExporter2]
diff --git a/mathics/builtin/forms/__init__.py b/mathics/builtin/forms/__init__.py
index a930b0314..08079cc3c 100644
--- a/mathics/builtin/forms/__init__.py
+++ b/mathics/builtin/forms/__init__.py
@@ -1,7 +1,8 @@
"""
Forms of Input and Output
-A Form format specifies the way Mathics Expression input is read or output written.
+A Form format specifies the way Mathics Expression input is read or output \
+written.
The variable :$OutputForms':
/doc/reference-of-built-in-symbols/forms-of-input-and-output/form-variables/$outputforms/ \
diff --git a/mathics/builtin/graphics.py b/mathics/builtin/graphics.py
index ea8588b32..f1ba9993b 100644
--- a/mathics/builtin/graphics.py
+++ b/mathics/builtin/graphics.py
@@ -5,9 +5,6 @@
Drawing Graphics
"""
-# This following line tells documentation how to sort this module
-sort_order = "mathics.builtin.drawing-graphics"
-
from math import sqrt
from mathics.builtin.base import Builtin
@@ -52,6 +49,9 @@
)
from mathics.eval.nevaluator import eval_N
+# This following line tells documentation how to sort this module
+sort_order = "mathics.builtin.drawing-graphics"
+
GRAPHICS_OPTIONS = {
"AspectRatio": "Automatic",
"Axes": "False",
@@ -431,7 +431,7 @@ class AbsoluteThickness(_Thickness):
= -Graphics-
"""
- summary_text = "graphics directive be specifying absolute line thickness"
+ summary_text = "graphics directive for the absolute line thickness"
def get_thickness(self):
return self.graphics.translate_absolute((self.value, 0))[0]
@@ -485,7 +485,7 @@ class PointSize(_Size):
= {-Graphics3D-, -Graphics3D-, -Graphics3D-}
"""
- summary_text = "graphics directive specifying relative sizes of points"
+ summary_text = "graphics directive for relative sizes of points"
def get_absolute_size(self):
if self.graphics.view_width is None:
@@ -592,7 +592,8 @@ class Polygon(Builtin):
Notice that there is a line connecting from the last point to the first one.
- A point is an element of the polygon if a ray from the point in any direction in the plane crosses the boundary line segments an odd number of times.
+ A point is an element of the polygon if a ray from the point in any direction in \
+ the plane crosses the boundary line segments an odd number of times.
>> Graphics[Polygon[{{150,0},{121,90},{198,35},{102,35},{179,90}}]]
= -Graphics-
@@ -600,7 +601,7 @@ class Polygon(Builtin):
= -Graphics3D-
"""
- summary_text = "a polygon in 2D or 3D"
+ summary_text = "graphics primitive for a polygon in 2D or 3D"
class RegularPolygon(Builtin):
@@ -628,7 +629,7 @@ class RegularPolygon(Builtin):
= -Graphics-
"""
- summary_text = "a regular polygon in 2D"
+ summary_text = "graphics primitve for a regular polygon in 2D"
class Arrow(Builtin):
@@ -645,10 +646,12 @@ class Arrow(Builtin):
- represents a line with arrow that keeps a distance of $s$ from $p1$ and $p2$.
- 'Arrow[{$point_1$, $point_2$}, {$s1$, $s2$}]'
-
- represents a line with arrow that keeps a distance of $s1$ from $p1$ and a distance of $s2$ from $p2$.
+
- represents a line with arrow that keeps a distance of $s1$ from $p1$ and a \
+ distance of $s2$ from $p2$.
- 'Arrow[{$point_1$, $point_2$}, {$s1$, $s2$}]'
-
- represents a line with arrow that keeps a distance of $s1$ from $p1$ and a distance of $s2$ from $p2$.
+
- represents a line with arrow that keeps a distance of $s1$ from $p1$ and a \
+ distance of $s2$ from $p2$.
>> Graphics[Arrow[{{0,0}, {1,1}}]]
@@ -668,7 +671,7 @@ class Arrow(Builtin):
= {-Graphics-, -Graphics-, -Graphics-, -Graphics-, -Graphics-}
"""
- summary_text = "graphics primitive to specify arbitrary graphical arrows"
+ summary_text = "graphics primitive for arbitrary graphical arrows"
class Arrowheads(_GraphicsDirective):
@@ -680,19 +683,24 @@ class Arrowheads(_GraphicsDirective):
- 'Arrowheads[$s$]'
-
- specifies that Arrow[] draws one arrow of size $s$ (relative to width of image, defaults to 0.04).
+
- specifies that Arrow[] draws one arrow of size $s$ (relative to width of \
+ image, defaults to 0.04).
- 'Arrowheads[{$spec1$, $spec2$, ..., $specn$}]'
-
- specifies that Arrow[] draws n arrows as defined by $spec1$, $spec2$, ... $specn$.
+
- specifies that Arrow[] draws n arrows as defined by $spec1$, $spec2$, \
+ ... $specn$.
- 'Arrowheads[{{$s$}}]'
- specifies that one arrow of size $s$ should be drawn.
- 'Arrowheads[{{$s$, $pos$}}]'
-
- specifies that one arrow of size $s$ should be drawn at position $pos$ (for the arrow to be on the line, $pos$ has to be between 0, i.e. the start for the line, and 1, i.e. the end of the line).
+
- specifies that one arrow of size $s$ should be drawn at position $pos$ (for \
+ the arrow to be on the line, $pos$ has to be between 0, i.e. the start for \
+ the line, and 1, i.e. the end of the line).
- 'Arrowheads[{{$s$, $pos$, $g$}}]'
-
- specifies that one arrow of size $s$ should be drawn at position $pos$ using Graphics $g$.
+
- specifies that one arrow of size $s$ should be drawn at position $pos$ \
+ using Graphics $g$.
Arrows on both ends can be achieved using negative sizes:
@@ -711,9 +719,7 @@ class Arrowheads(_GraphicsDirective):
default_size = 0.04
- summary_text = (
- "graphics directive specifying the form and placement of an arrowhead"
- )
+ summary_text = "graphics directive for the form and placement of an arrowhead"
symbolic_sizes = {
"System`Tiny": 3,
@@ -1232,7 +1238,7 @@ class Circle(Builtin):
"""
rules = {"Circle[]": "Circle[{0, 0}]"}
- summary_text = "empty circle, ellipse, or arc graphics primitive"
+ summary_text = "graphics primitive for an empty circle, ellipse, or arc"
class Disk(Builtin):
@@ -1493,7 +1499,7 @@ class Thickness(_Thickness):
= -Graphics-
"""
- summary_text = "graphics directive to specify line thicknesses"
+ summary_text = "graphics directive for line thicknesses"
def get_thickness(self):
return self.graphics.translate_relative(self.value)
diff --git a/mathics/builtin/image/__init__.py b/mathics/builtin/image/__init__.py
index 63ccbaae0..c71d944f7 100644
--- a/mathics/builtin/image/__init__.py
+++ b/mathics/builtin/image/__init__.py
@@ -2,5 +2,7 @@
Image Manipulation
-For the full compliment of functions, you need to have scikit-image installed.
+For the full compliment of functions, you need to have :scikit-image:
+https://scikit-image.org/
+installed.
"""
diff --git a/mathics/builtin/layout.py b/mathics/builtin/layout.py
index 7d01543f9..0397b09b3 100644
--- a/mathics/builtin/layout.py
+++ b/mathics/builtin/layout.py
@@ -420,7 +420,7 @@ class Style(Builtin):
"""
- summary_text = "wrapper specifying styles and style options to apply"
+ summary_text = "wrapper for styles and style options to apply"
options = {"ImageSizeMultipliers": "Automatic"}
rules = {
diff --git a/mathics/builtin/lowlevelprofile.py b/mathics/builtin/lowlevelprofile.py
deleted file mode 100644
index 033a2d4f4..000000000
--- a/mathics/builtin/lowlevelprofile.py
+++ /dev/null
@@ -1,56 +0,0 @@
-# -*- coding: utf-8 -*-
-
-"""
-Low-level Profiling
-
-Low-level (Python) profile from inside the Mathics3 interpreter
-
-"""
-
-import cProfile
-import pstats
-import sys
-from io import StringIO
-
-from mathics.builtin.base import Builtin
-from mathics.core.attributes import A_HOLD_ALL_COMPLETE, A_PROTECTED
-from mathics.core.convert.python import from_python
-from mathics.core.evaluation import Evaluation
-from mathics.core.expression import Expression
-from mathics.core.list import ListExpression
-from mathics.core.symbols import SymbolNull
-
-
-class PythonCProfileEvaluation(Builtin):
- """
- :Python:https://docs.python.org/3/library/profile.html
-
-
- - 'PythonProfileEvaluation[$expr$]'
-
- profile $expr$ with the Python's cProfiler.
-
-
- >> PythonCProfileEvaluation[a + b + 1]
- = ...
- """
-
- attributes = A_HOLD_ALL_COMPLETE | A_PROTECTED
- summary_text = "profile the internal evaluation of an expression"
-
- def eval(self, expr: Expression, evaluation: Evaluation):
- "PythonCProfileEvaluation[expr_]"
- profile_result = SymbolNull
- textstream = StringIO()
- if sys.version_info >= (3, 8):
- with cProfile.Profile() as pr:
- result = expr.evaluate(evaluation)
- stats = pstats.Stats(pr, stream=textstream)
- stats.strip_dirs().sort_stats(-1).print_stats()
- # TODO: convert the string (or the statistics)
- # into something like a WL Table, by splitting the
- # rows and the columns. By now, just a string
- # is returned.
- profile_result = from_python(textstream.getvalue())
- else:
- result = expr.evaluate(evaluation)
- return ListExpression(result, profile_result)
diff --git a/mathics/builtin/numbers/hyperbolic.py b/mathics/builtin/numbers/hyperbolic.py
index 774c0f386..44670b15c 100644
--- a/mathics/builtin/numbers/hyperbolic.py
+++ b/mathics/builtin/numbers/hyperbolic.py
@@ -262,7 +262,7 @@ class ComplexExpand(SympyFunction):
'ComplexExpand[$expr$]'
expands $expr$ assuming that all variables are real.
- 'ComplexExpand[$expr$,{$x1$,$x2$, ...}]
+ 'ComplexExpand[$expr$,{$x1$,$x2$, ...}]'
expands $expr$ assuming that variables matching any of the $xi$ are complex.
diff --git a/mathics/builtin/optiondoc.py b/mathics/builtin/optiondoc.py
index 09331bced..a4d3592f1 100644
--- a/mathics/builtin/optiondoc.py
+++ b/mathics/builtin/optiondoc.py
@@ -3,13 +3,11 @@
"""
Drawing Options and Option Values
-The various common Plot and Graphics options, along with the meaning of specific option values are described here.
+The various common Plot and Graphics options, along with the meaning of specific \
+option values are described here.
"""
-# This tells documentation how to sort this module
-sort_order = "mathics.builtin.drawing-options-and-option-values"
-
# Until we have a better documentation system in place, we define classes for
# options. They are Builtins, even though they largely aren't.
#
@@ -19,6 +17,9 @@
from mathics.builtin.base import Builtin
+# This tells documentation how to sort this module
+sort_order = "mathics.builtin.drawing-options-and-option-values"
+
class Automatic(Builtin):
"""
@@ -99,14 +100,15 @@ class ChartLabels(Builtin):
- 'ChartLabels'
-
- is a charting option that specifies what labels should be used for chart elements.
+
- is a charting option that specifies what labels should be used for chart \
+ elements.
>> PieChart[{30, 20, 10}, ChartLabels -> {Dogs, Cats, Fish}]
= -Graphics-
"""
- summary_text = "charting option specifying whether to label chart"
+ summary_text = "charting option for whether to label chart"
class ChartLegends(Builtin):
@@ -115,11 +117,12 @@ class ChartLegends(Builtin):
- 'ChartLegends'
-
- is an option for charting functions that specifies the legends to be used for chart elements.
+
- is an option for charting functions that specifies the legends to be used \
+ for chart elements.
"""
- summary_text = "chart option giving legends to a chart"
+ summary_text = "chart option for giving legends to a chart"
class Filling(Builtin):
@@ -173,7 +176,7 @@ class ImageSize(Builtin):
= -Graphics-
"""
- summary_text = "image option specifying the size of the final picture"
+ summary_text = "image option for the size of the final picture"
class Joined(Builtin):
@@ -200,7 +203,8 @@ class MaxRecursion(Builtin):
- 'MaxRecursion'
-
- is an option for functions like NIntegrate and Plot that specifies how many recursive subdivisions can be made.
+
- is an option for functions like NIntegrate and Plot that specifies how many \
+ recursive subdivisions can be made.
>> NIntegrate[Exp[-10^8 x^2], {x, -1, 1}, Method->"Internal", MaxRecursion -> 3]
@@ -209,7 +213,10 @@ class MaxRecursion(Builtin):
= 0.00972222
"""
- summary_text = "function option specifying the maximum number of recursive subdivisions the function can perform"
+ summary_text = (
+ "function option for the maximum number of recursive "
+ "subdivisions the function can perform"
+ )
class Mesh(Builtin):
@@ -218,7 +225,8 @@ class Mesh(Builtin):
- 'Mesh'
-
- is a charting option, such as for 'Plot', 'BarChart', 'PieChart', etc. that specifies the mesh to be drawn. The default is 'Mesh->None'.
+
- is a charting option, such as for 'Plot', 'BarChart', 'PieChart', etc. that \
+ specifies the mesh to be drawn. The default is 'Mesh->None'.
>> Plot[Sin[Cos[x^2]],{x,-4,4},Mesh->All]
@@ -293,7 +301,8 @@ class TicksStyle(Builtin):
- 'TicksStyle'
-
- is an option for graphics functions which specifies how ticks should be rendered.
+
- is an option for graphics functions which specifies how ticks should be \
+ rendered.
@@ -306,7 +315,7 @@ class TicksStyle(Builtin):
= -Graphics-
"""
- summary_text = "graph option specifying the format of tick marks on axes"
+ summary_text = "graph option for the format of tick marks on axes"
class Top(Builtin):
diff --git a/mathics/builtin/options.py b/mathics/builtin/options.py
index 7e01f61f6..5c52e5459 100644
--- a/mathics/builtin/options.py
+++ b/mathics/builtin/options.py
@@ -39,7 +39,8 @@ class All(Predefined):
For example, in
:Part:
/doc/reference-of-built-in-symbols/list-functions/elements-of-lists/part, \
- 'All', extracts into a first column vector the first element of each of the list elements:
+ 'All', extracts into a first column vector the first element of each of the \
+ list elements:
>> {{1, 3}, {5, 7}}[[All, 1]]
= {1, 5}
@@ -47,7 +48,8 @@ class All(Predefined):
While in
:Take:
/doc/reference-of-built-in-symbols/list-functions/elements-of-lists/part, \
- 'All' extracts as a column matrix the first element as a list for each of the list elements:
+ 'All' extracts as a column matrix the first element as a list for each of the list \
+ elements:
>> Take[{{1, 3}, {5, 7}}, All, {1}]
= {{1}, {5}}
@@ -169,21 +171,21 @@ def matched():
class None_(Predefined):
"""
- :WMA link:https://reference.wolfram.com/language/ref/None.html
+ :WMA link:https://reference.wolfram.com/language/ref/None.html
-
- - 'None'
-
- is a setting value for many options.
-
+
+ - 'None'
+
- is a setting value for many options.
+
- Plot3D shows the mesh grid between computed points by default. This the
- :Mesh:
- /doc/reference-of-built-in-symbols/drawing-option-and-values/mesh option.
+ Plot3D shows the mesh grid between computed points by default. This the
+ :Mesh:
+ /doc/reference-of-built-in-symbols/drawing-options-and-option-values/mesh option.
- However, you hide the mesh by setting the 'Mesh' option value to 'None':
+ However, you hide the mesh by setting the 'Mesh' option value to 'None':
- >> Plot3D[{x^2 + y^2, -x^2 - y^2}, {x, -2, 2}, {y, -2, 2}, BoxRatios-> Automatic, Mesh->None]
- = -Graphics3D-
+ >> Plot3D[{x^2 + y^2, -x^2 - y^2}, {x, -2, 2}, {y, -2, 2}, BoxRatios-> Automatic, Mesh->None]
+ = -Graphics3D-
"""
name = "None"
diff --git a/mathics/builtin/trace.py b/mathics/builtin/trace.py
index 3cca7c8c4..759c4df31 100644
--- a/mathics/builtin/trace.py
+++ b/mathics/builtin/trace.py
@@ -1,25 +1,34 @@
# -*- coding: utf-8 -*-
"""
-Tracing Built-in Functions
+Tracing and Profiling
-Built-in Function Tracing provides one high-level way understand what is \
+The 'Trace' builtins provide a Mathics3-oriented trace of what is \
getting evaluated and where the time is spent in evaluation.
With this, it may be possible for both users and implementers to follow \
how Mathics3 arrives at its results, or guide how to speed up expression \
evaluation.
+
+Python :CProfile:https://docs.python.org/3/library/profile.html \
+profiling is available via 'PythonCProfileEvaluation'.
"""
+import cProfile
+import pstats
+import sys
from collections import defaultdict
+from io import StringIO
from time import time
from typing import Callable
from mathics.builtin.base import Builtin
-from mathics.core.attributes import A_HOLD_ALL, A_PROTECTED
-from mathics.core.convert.python import from_bool
+from mathics.core.attributes import A_HOLD_ALL, A_HOLD_ALL_COMPLETE, A_PROTECTED
+from mathics.core.convert.python import from_bool, from_python
from mathics.core.definitions import Definitions
from mathics.core.evaluation import Evaluation
+from mathics.core.expression import Expression
+from mathics.core.list import ListExpression
from mathics.core.rules import BuiltinRule
from mathics.core.symbols import SymbolFalse, SymbolNull, SymbolTrue, strip_context
@@ -110,7 +119,8 @@ class PrintTrace(_TraceBase):
Note that in a browser the information only appears in a console.
- If '$TraceBuiltins' was never set to 'True', this will print an empty list.
+ Note: before '$TraceBuiltins' is set to 'True', 'PrintTrace[]' will print an empty
+ list.
>> PrintTrace[]
>> $TraceBuiltins = True
@@ -158,7 +168,12 @@ class TraceBuiltins(_TraceBase):
>> TraceBuiltins[Graphics3D[Tetrahedron[]]]
= -Graphics3D-
- By default, the output is sorted by the number of calls of the builtin from highest to lowest:
+ By default, the output is sorted by the name:
+ >> TraceBuiltins[Times[x, x]]
+ = x ^ 2
+
+ By default, the output is sorted by the number of calls of the builtin from \
+ highest to lowest:
>> TraceBuiltins[Times[x, x], SortBy->"count"]
= x ^ 2
@@ -189,17 +204,26 @@ def dump_tracing_stats(sort_by: str, evaluation) -> None:
sort_by = "count"
print()
+ def sort_by_count(tup: tuple):
+ return tup[1]["count"]
+
+ def sort_by_time(tup: tuple):
+ return tup[1]["elapsed_milliseconds"]
+
+ def sort_by_name(tup: tuple):
+ return tup[0]
+
print("count ms Builtin name")
if sort_by == "count":
inverse = True
- sort_fn = lambda tup: tup[1]["count"]
+ sort_fn = sort_by_count
elif sort_by == "time":
inverse = True
- sort_fn = lambda tup: tup[1]["elapsed_milliseconds"]
+ sort_fn = sort_by_time
else:
inverse = False
- sort_fn = lambda tup: tup[0]
+ sort_fn = sort_by_name
for name, statistic in sorted(
TraceBuiltins.function_stats.items(),
@@ -260,9 +284,12 @@ class TraceBuiltinsVariable(Builtin):
- A Boolean Built-in variable when True collects function evaluation statistics.
- Setting this variable True will enable statistics collection for Built-in functions that are evaluated.
- In contrast to 'TraceBuiltins[]' statistics are accumulated and over several inputs, and are not shown after each input is evaluated.
- By default this setting is False.
+ Setting this variable True will enable statistics collection for Built-in \
+ functions that are evaluated.
+ In contrast to 'TraceBuiltins[]' statistics are accumulated and over several \
+ inputs,and are not shown after each input is evaluated.
+
+ By default, this setting is False.
>> $TraceBuiltins = True
= True
@@ -271,7 +298,8 @@ class TraceBuiltinsVariable(Builtin):
#> $TraceBuiltins = False
= False
- Tracing is enabled, so the expressions entered and evaluated will have statistics collected for the evaluations.
+ Tracing is enabled, so the expressions entered and evaluated will have statistics \
+ collected for the evaluations.
>> x
= x
@@ -407,3 +435,38 @@ def eval_set(self, value, evaluation: Evaluation):
evaluation.message("$TraceEvaluation", "bool", value)
return value
+
+
+class PythonCProfileEvaluation(Builtin):
+ """
+ :Python:https://docs.python.org/3/library/profile.html
+
+
+ - 'PythonProfileEvaluation[$expr$]'
+
- profile $expr$ with the Python's cProfiler.
+
+
+ >> PythonCProfileEvaluation[a + b + 1]
+ = ...
+ """
+
+ attributes = A_HOLD_ALL_COMPLETE | A_PROTECTED
+ summary_text = "profile the internal evaluation of an expression"
+
+ def eval(self, expr: Expression, evaluation: Evaluation):
+ "PythonCProfileEvaluation[expr_]"
+ profile_result = SymbolNull
+ textstream = StringIO()
+ if sys.version_info >= (3, 8):
+ with cProfile.Profile() as pr:
+ result = expr.evaluate(evaluation)
+ stats = pstats.Stats(pr, stream=textstream)
+ stats.strip_dirs().sort_stats(-1).print_stats()
+ # TODO: convert the string (or the statistics)
+ # into something like a WL Table, by splitting the
+ # rows and the columns. By now, just a string
+ # is returned.
+ profile_result = from_python(textstream.getvalue())
+ else:
+ result = expr.evaluate(evaluation)
+ return ListExpression(result, profile_result)
diff --git a/mathics/doc/common_doc.py b/mathics/doc/common_doc.py
index 38a134f9a..f6c1a169e 100644
--- a/mathics/doc/common_doc.py
+++ b/mathics/doc/common_doc.py
@@ -123,7 +123,7 @@
def _replace_all(text, pairs):
- for (i, j) in pairs:
+ for i, j in pairs:
text = text.replace(i, j)
return text
@@ -367,6 +367,7 @@ def add_section(
operator,
is_guide: bool = False,
in_guide: bool = False,
+ summary_text="",
):
"""
Adds a DocSection or DocGuideSection
@@ -397,6 +398,7 @@ def add_section(
operator=operator,
installed=installed,
in_guide=in_guide,
+ summary_text=summary_text,
)
chapter.sections.append(section)
@@ -456,6 +458,7 @@ def doc_part(self, title, modules, builtins_by_module, start):
builtin_part = self.doc_part_fn(self, title, is_reference=start)
modules_seen = set([])
+ submodule_names_seen = set([])
want_sorting = True
if want_sorting:
@@ -504,6 +507,8 @@ def doc_part(self, title, modules, builtins_by_module, start):
continue
submodule_name = get_doc_name_from_module(submodule)
+ if submodule_name in submodule_names_seen:
+ continue
section = self.add_section(
chapter,
submodule_name,
@@ -513,6 +518,7 @@ def doc_part(self, title, modules, builtins_by_module, start):
in_guide=True,
)
modules_seen.add(submodule)
+ submodule_names_seen.add(submodule_name)
guide_section.subsections.append(section)
builtins = builtins_by_module.get(submodule.__name__, [])
@@ -521,13 +527,17 @@ def doc_part(self, title, modules, builtins_by_module, start):
if hasattr(instance, "no_doc") and instance.no_doc:
continue
- modules_seen.add(instance)
name = instance.get_name(short=True)
+ if name in submodule_names_seen:
+ continue
+
+ submodule_names_seen.add(name)
+ modules_seen.add(instance)
self.add_subsection(
chapter,
section,
- instance.get_name(short=True),
+ name,
instance,
instance.get_operator(),
in_guide=True,
@@ -548,6 +558,9 @@ def doc_sections(self, sections, modules_seen, chapter):
not hasattr(instance, "no_doc") or not instance.no_doc
):
name = instance.get_name(short=True)
+ summary_text = (
+ instance.summary_text if hasattr(instance, "summary_text") else ""
+ )
self.add_section(
chapter,
name,
@@ -555,6 +568,7 @@ def doc_sections(self, sections, modules_seen, chapter):
instance.get_operator(),
is_guide=False,
in_guide=False,
+ summary_text=summary_text,
)
modules_seen.add(instance)
@@ -771,7 +785,6 @@ def __init__(
in_guide=False,
summary_text="",
):
-
self.chapter = chapter
self.in_guide = in_guide
self.installed = installed