Skip to content

Commit

Permalink
Another round of docstring improvments
Browse files Browse the repository at this point in the history
Also some linting
  • Loading branch information
rocky committed Jan 20, 2025
1 parent 3f1fb46 commit 9a5d61d
Show file tree
Hide file tree
Showing 8 changed files with 190 additions and 104 deletions.
22 changes: 14 additions & 8 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ New Builtins
++++++++++++

* ``Between``
* ``Breakpoint`` - forces a Python ``breakpoint()``
* ``CheckAbort``
* ``FileNameDrop``
* ``SetEnvironment``
Expand Down Expand Up @@ -56,7 +57,7 @@ Internals
tables produced from the Mathics Scanner project.
* Patterns in ``eval_`` and ``format_`` methods of builtin classes
parses patterns in docstrings of the form
``Symbol: Expr`` as `Pattern[Symbol, Expr]`.
``Symbol: Expr`` as ``Pattern[Symbol, Expr]``.
To specify associated format in ``format_`` methods the
docstring, the list of format must be wrapped in parenthesis, like
``(InputForm,): Definitions[...]`` instead of just ``InputForm: Definitions[...]``.
Expand Down Expand Up @@ -85,13 +86,18 @@ Bugs
Mathics3 Packages
+++++++++++++++++

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


Mathics3 Modules
++++++++++++++++

* Added preliminary Mathics3 debugger ("pymathics.trepan")

Python Package Updates
+++++++++++++++++++++++

Expand Down Expand Up @@ -808,13 +814,13 @@ New variables and builtins
Enhancements
++++++++++++

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


Pymathics Modules
+++++++++++++++++
Mathics3 Modules
++++++++++++++++

#. Pymathics modules now can run initialization code when are loaded.
#. Mathics3 modules now can run initialization code when are loaded.
#. The ``builtins`` list is not hard-linked to the library anymore. This simplifies the loading and reloading of pymathics modules.
#. 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.

Expand Down
19 changes: 12 additions & 7 deletions mathics/builtin/file_operations/file_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class FileDate(Builtin):
"Change" -> FileDate[filepath, "Change"],
"Modification" -> FileDate[filepath, "Modification"]}""",
}
summary_text = "date and time of the last change in a file"
summary_text = "get date and time of the last change in a file"

def eval(self, path, timetype, evaluation):
"FileDate[path_, timetype_]"
Expand Down Expand Up @@ -107,7 +107,10 @@ def eval(self, path, timetype, evaluation):
epochtime_expr = Expression(
SymbolAbsoluteTime, String(time.strftime("%Y-%m-%d %H:%M", time.gmtime(0)))
)
epochtime = eval_N(epochtime_expr, evaluation).to_python()
epochtime_N = eval_N(epochtime_expr, evaluation)
if epochtime_N is None:
return None
epochtime = epochtime_N.to_python()
result += epochtime

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

def eval(self, filename, evaluation):
"FileType[filename_]"
Expand All @@ -210,7 +213,7 @@ def eval(self, filename, evaluation):
return
path = filename.to_python()[1:-1]

path, is_temporary_file = path_search(path)
path, _ = path_search(path)

if path is None:
return SymbolNone
Expand Down Expand Up @@ -288,7 +291,7 @@ def eval(self, filename, datelist, attribute, evaluation):
):
evaluation.message("SetFileDate", "fstr", filename)
return
py_filename, is_temporary_file = path_search(py_filename[1:-1])
py_filename, _ = path_search(py_filename[1:-1])

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

stattime = to_expression("AbsoluteTime", from_python(py_datelist))
stattime = eval_N(stattime, evaluation).to_python()
stattime_N = eval_N(stattime, evaluation)
if stattime_N is None:
return

stattime -= epochtime
stattime = stattime_N.to_python() - epochtime

try:
os.stat(py_filename)
Expand Down
4 changes: 2 additions & 2 deletions mathics/builtin/forms/other.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class SequenceForm(FormBaseClass):
"CharacterEncoding": '"Unicode"',
}

summary_text = "format make an string from a template and a list of parameters"
summary_text = "format a string from a template and a list of parameters"

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

in_outputforms = False
in_printforms = False
summary_text = "make an string from a template and a list of parameters"
summary_text = "format a string from a template and a list of parameters"

def eval_makeboxes(self, s, args, form, evaluation):
"""MakeBoxes[StringForm[s_String, args___],
Expand Down
7 changes: 6 additions & 1 deletion mathics/builtin/intfns/combinatorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,12 @@ class EulerE(SympyFunction):
<dd>Euler polynomial $E$_$n$($x$).
</dl>
>> Table[EulerE[k], {k, 0, 10}]
Odd-index Euler numbers are zero:
>> Table[EulerE[k], {k, 1, 9, 2}]
= {1, 0, -1, 0, 5, 0, -61, 0, 1385, 0, -50521}
Even-index Euler numbers alternate in sign:
>> Table[EulerE[k], {k, 0, 8, 2}]
= {1, 0, -1, 0, 5, 0, -61, 0, 1385, 0, -50521}
>> EulerE[5, z]
Expand Down
Loading

0 comments on commit 9a5d61d

Please sign in to comment.