Skip to content

Commit

Permalink
Administrative fixups and tweak (#1254)
Browse files Browse the repository at this point in the history
Miscellaneous docstring hard linebreaks removed and some mypy linting.
  • Loading branch information
rocky authored Dec 29, 2024
1 parent 43961e0 commit 41f198c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions mathics/builtin/functional/functional_iteration.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ class Nest(Builtin):
= f[f[f[x]]]
>> Nest[(1+#) ^ 2 &, x, 2]
= (1 + (1 + x) ^ 2) ^ 2
>> Nest[Subsuperscript[#,#,#]&,0,5]
= ...
"""

summary_text = "give the result of nesting a function"
Expand Down
8 changes: 4 additions & 4 deletions mathics/builtin/list/constructing.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class List(Builtin):
attributes = A_LOCKED | A_PROTECTED
summary_text = "form a list"

def eval(self, elements, evaluation):
def eval(self, elements, evaluation: Evaluation):
"""List[elements___]"""
# Pick out the elements part of the parameter elements;
# we we will call that `elements_part_of_elements__`.
Expand Down Expand Up @@ -464,7 +464,7 @@ def listener(e, tag):
try:
result = expr.evaluate(evaluation)
items = []
for pattern, tags in sown:
for _, tags in sown:
list_of_elements = []
for tag, elements in tags:
list_of_elements.append(
Expand Down Expand Up @@ -521,11 +521,11 @@ class Table(IterationFunction):
<dd>generates a list of the values of expr when $i$ runs from 1 to $n$.
<dt>'Table[$expr$, {$i$, $start$, $stop$, $step$}]'
<dd>evaluates $expr$ with $i$ ranging from $start$ to $stop$,
<dd>evaluates $expr$ with $i$ ranging from $start$ to $stop$, \
incrementing by $step$.
<dt>'Table[$expr$, {$i$, {$e1$, $e2$, ..., $ei$}}]'
<dd>evaluates $expr$ with $i$ taking on the values $e1$, $e2$,
<dd>evaluates $expr$ with $i$ taking on the values $e1$, $e2$, \
..., $ei$.
</dl>
Expand Down
6 changes: 3 additions & 3 deletions mathics/core/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,13 +925,13 @@ def get_name(cls, short=False) -> str:
return re.sub(r"Atom$", "", name)


class IterationFunction(Builtin):
class IterationFunction(Builtin, ABC):
attributes = A_HOLD_ALL | A_PROTECTED
allow_loopcontrol = False
throw_iterb = True

def get_result(self, items):
pass
def get_result(self, elements) -> ListExpression:
raise NotImplementedError

def eval_symbol(self, expr, iterator, evaluation):
"%(name)s[expr_, iterator_Symbol]"
Expand Down

0 comments on commit 41f198c

Please sign in to comment.