Skip to content

Commit d2e50ed

Browse files
authored
Another round of docstring improvments (#1306)
Also some linting
1 parent 3846c21 commit d2e50ed

File tree

8 files changed

+191
-105
lines changed

8 files changed

+191
-105
lines changed

CHANGES.rst

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ New Builtins
66
++++++++++++
77

88
* ``Between``
9+
* ``Breakpoint`` - forces a Python ``breakpoint()``
910
* ``CheckAbort``
1011
* ``FileNameDrop``
1112
* ``FormatValues``
@@ -57,7 +58,7 @@ Internals
5758
tables produced from the Mathics Scanner project.
5859
* Patterns in ``eval_`` and ``format_`` methods of builtin classes
5960
parses patterns in docstrings of the form
60-
``Symbol: Expr`` as `Pattern[Symbol, Expr]`.
61+
``Symbol: Expr`` as ``Pattern[Symbol, Expr]``.
6162
To specify associated format in ``format_`` methods the
6263
docstring, the list of format must be wrapped in parenthesis, like
6364
``(InputForm,): Definitions[...]`` instead of just ``InputForm: Definitions[...]``.
@@ -86,13 +87,18 @@ Bugs
8687
Mathics3 Packages
8788
+++++++++++++++++
8889

89-
* ``BoolEval``
90-
* ``CleanSlate``
90+
* Added ``BoolEval``
91+
* Added ``CleanSlate``
9192
* ``Combinatorica`` moved to a separate repository and v.9 renamed to 0.9.1.
9293
More code v0.9.1 works. v2.0 renamed v2.0.1 and some code now works.
9394
* ``Rubi`` version 4.17 (work in progress; algebraic integrations work)
9495

9596

97+
Mathics3 Modules
98+
++++++++++++++++
99+
100+
* Added preliminary Mathics3 debugger ("pymathics.trepan")
101+
96102
Python Package Updates
97103
+++++++++++++++++++++++
98104

@@ -809,13 +815,13 @@ New variables and builtins
809815
Enhancements
810816
++++++++++++
811817

812-
#. a function `evaluate_predicate` allows for a basic predicate evaluation using `$Assumptions`.
818+
#. a function ``evaluate_predicate`` allows for a basic predicate evaluation using ``$Assumptions``.
813819
#. ``Attributes`` accepts a string parameter.
814820
#. ``Cases`` accepts Heads option. Issue #1302.
815821
#. ``ColorNegate`` for colors is supported.
816822
#. ``D`` and ``Derivative`` improvements.
817823
#. ``Expand`` and ``ExpandAll`` now support a second parameter ``patt`` Issue #1301.
818-
#. ``Expand`` and ``ExpandAll`` works with hyperbolic functions (`Sinh`, `Cosh`, `Tanh`, `Coth`).
824+
#. ``Expand`` and ``ExpandAll`` works with hyperbolic functions (``Sinh``, ``Cosh``, ``Tanh``, ``Coth``).
819825
#. ``FileNames`` returns a sorted list. Issue #1250.
820826
#. ``FindRoot`` now accepts several optional parameters like ``Method`` and ``MaxIterations``. See Issue #1235.
821827
#. ``FixedPoint`` now supports the ``SameTest`` option.
@@ -900,10 +906,10 @@ Bug fixes
900906
``TeXForm[]`` for integrals are now properly formatted.
901907

902908

903-
Pymathics Modules
904-
+++++++++++++++++
909+
Mathics3 Modules
910+
++++++++++++++++
905911

906-
#. Pymathics modules now can run initialization code when are loaded.
912+
#. Mathics3 modules now can run initialization code when are loaded.
907913
#. The ``builtins`` list is not hard-linked to the library anymore. This simplifies the loading and reloading of pymathics modules.
908914
#. Decoupling of BoxConstructors from the library. Now are defined at the level of the definition objects. This is useful for customizing the Graphics output if it is available.
909915

mathics/builtin/file_operations/file_properties.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class FileDate(Builtin):
6767
"Change" -> FileDate[filepath, "Change"],
6868
"Modification" -> FileDate[filepath, "Modification"]}""",
6969
}
70-
summary_text = "date and time of the last change in a file"
70+
summary_text = "get date and time of the last change in a file"
7171

7272
def eval(self, path, timetype, evaluation):
7373
"FileDate[path_, timetype_]"
@@ -107,7 +107,10 @@ def eval(self, path, timetype, evaluation):
107107
epochtime_expr = Expression(
108108
SymbolAbsoluteTime, String(time.strftime("%Y-%m-%d %H:%M", time.gmtime(0)))
109109
)
110-
epochtime = eval_N(epochtime_expr, evaluation).to_python()
110+
epochtime_N = eval_N(epochtime_expr, evaluation)
111+
if epochtime_N is None:
112+
return None
113+
epochtime = epochtime_N.to_python()
111114
result += epochtime
112115

113116
return to_expression("DateList", Real(result))
@@ -201,7 +204,7 @@ class FileType(Builtin):
201204
"File specification `1` is not a string of " "one or more characters."
202205
),
203206
}
204-
summary_text = "type of a file"
207+
summary_text = "get the file extension or file type of a file"
205208

206209
def eval(self, filename, evaluation):
207210
"FileType[filename_]"
@@ -210,7 +213,7 @@ def eval(self, filename, evaluation):
210213
return
211214
path = filename.to_python()[1:-1]
212215

213-
path, is_temporary_file = path_search(path)
216+
path, _ = path_search(path)
214217

215218
if path is None:
216219
return SymbolNone
@@ -288,7 +291,7 @@ def eval(self, filename, datelist, attribute, evaluation):
288291
):
289292
evaluation.message("SetFileDate", "fstr", filename)
290293
return
291-
py_filename, is_temporary_file = path_search(py_filename[1:-1])
294+
py_filename, _ = path_search(py_filename[1:-1])
292295

293296
if py_filename is None:
294297
evaluation.message("SetFileDate", "nffil", expr)
@@ -317,9 +320,11 @@ def eval(self, filename, datelist, attribute, evaluation):
317320
)
318321

319322
stattime = to_expression("AbsoluteTime", from_python(py_datelist))
320-
stattime = eval_N(stattime, evaluation).to_python()
323+
stattime_N = eval_N(stattime, evaluation)
324+
if stattime_N is None:
325+
return
321326

322-
stattime -= epochtime
327+
stattime = stattime_N.to_python() - epochtime
323328

324329
try:
325330
os.stat(py_filename)

mathics/builtin/forms/other.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class SequenceForm(FormBaseClass):
3737
"CharacterEncoding": '"Unicode"',
3838
}
3939

40-
summary_text = "format make an string from a template and a list of parameters"
40+
summary_text = "format a string from a template and a list of parameters"
4141

4242
def eval_makeboxes(self, args, form, evaluation, options: dict):
4343
"""MakeBoxes[SequenceForm[args___, OptionsPattern[SequenceForm]],
@@ -73,7 +73,7 @@ class StringForm(FormBaseClass):
7373

7474
in_outputforms = False
7575
in_printforms = False
76-
summary_text = "make an string from a template and a list of parameters"
76+
summary_text = "format a string from a template and a list of parameters"
7777

7878
def eval_makeboxes(self, s, args, form, evaluation):
7979
"""MakeBoxes[StringForm[s_String, args___],

mathics/builtin/intfns/combinatorial.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,13 @@ class EulerE(SympyFunction):
230230
<dd>Euler polynomial $E$_$n$($x$).
231231
</dl>
232232
233-
>> Table[EulerE[k], {k, 0, 10}]
234-
= {1, 0, -1, 0, 5, 0, -61, 0, 1385, 0, -50521}
233+
Odd-index Euler numbers are zero:
234+
>> Table[EulerE[k], {k, 1, 9, 2}]
235+
= {0, 0, 0, 0, 0}
236+
237+
Even-index Euler numbers alternate in sign:
238+
>> Table[EulerE[k], {k, 0, 8, 2}]
239+
= {1, -1, 5, -61, 1385}
235240
236241
>> EulerE[5, z]
237242
= -1 / 2 + 5 z ^ 2 / 2 - 5 z ^ 4 / 2 + z ^ 5

0 commit comments

Comments
 (0)