Skip to content

Commit 1b27bc2

Browse files
authored
Doc updates (#1297)
First part of an unknown number of rounds of documentation review.
1 parent c37c237 commit 1b27bc2

File tree

8 files changed

+81
-73
lines changed

8 files changed

+81
-73
lines changed

mathics/builtin/arithmetic.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ class I_(Predefined, SympyObject):
627627
name = "I"
628628
sympy_name = "I"
629629
sympy_obj = sympy.I
630-
summary_text = "imaginary unit"
630+
summary_text = "imaginary unit number Sqrt[-1]"
631631
python_equivalent = 1j
632632

633633
def is_constant(self) -> bool:
@@ -658,7 +658,7 @@ class Im(SympyFunction):
658658
= -Graphics-
659659
"""
660660

661-
summary_text = "imaginary part"
661+
summary_text = "imaginary part of a complex number"
662662
attributes = A_LISTABLE | A_NUMERIC_FUNCTION | A_PROTECTED
663663

664664
def eval_complex(self, number, evaluation: Evaluation):
@@ -817,10 +817,14 @@ class Re(SympyFunction):
817817
= -Graphics-
818818
"""
819819

820-
summary_text = "real part"
820+
summary_text = "real part of a complex number"
821821
attributes = A_LISTABLE | A_NUMERIC_FUNCTION | A_PROTECTED
822822
sympy_name = "re"
823823

824+
def eval(self, number, evaluation: Evaluation):
825+
"Re[number_]"
826+
return from_sympy(sympy.re(number.to_sympy().expand(complex=True)))
827+
824828
def eval_complex(self, number, evaluation: Evaluation):
825829
"Re[number_Complex]"
826830
if isinstance(number, Complex):
@@ -831,10 +835,6 @@ def eval_number(self, number, evaluation: Evaluation):
831835

832836
return number
833837

834-
def eval(self, number, evaluation: Evaluation):
835-
"Re[number_]"
836-
return from_sympy(sympy.re(number.to_sympy().expand(complex=True)))
837-
838838

839839
class Real_(Builtin):
840840
"""
@@ -987,8 +987,8 @@ class Sum(IterationFunction, SympyFunction):
987987
}
988988
)
989989

990-
def get_result(self, items):
991-
return Expression(SymbolPlus, *items)
990+
def get_result(self, elements) -> Expression:
991+
return Expression(SymbolPlus, *elements)
992992

993993
def to_sympy(self, expr, **kwargs) -> Optional[SympyExpression]:
994994
"""

mathics/builtin/files_io/importexport.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1327,7 +1327,7 @@ class Import(Builtin):
13271327
<dd>imports the specified elements from a file.
13281328
13291329
<dt>'Import["$file$", {"$fmt$", $elements$}]'
1330-
<dd>imports the specified elements from a file asuming the specified file format.
1330+
<dd>imports the specified elements from a file assuming the specified file format.
13311331
13321332
<dt>'Import["http://$url$", ...]' and 'Import["ftp://$url$", ...]'
13331333
<dd>imports from a URL.

mathics/builtin/functional/apply_fns_to_lists.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,21 +173,21 @@ class MapAt(Builtin):
173173
<dd>applies $f$ to the part of $expr$ at position {$i$, $j$, ...}.
174174
175175
<dt>'MapAt[$f$, $pos$]'
176-
<dd>represents an operator form of MapAt that can be applied to an expression.
176+
<dd>represents an operator form of 'MapAt' that can be applied to an expression.
177177
</dl>
178178
179179
Map function $f$ to the second element of an simple flat list:
180180
>> MapAt[f, {a, b, c}, 2]
181181
= {a, f[b], c}
182182
183-
Above we specified a simple integer value 2. In general, the expression can an arbitrary vector.
183+
Above, we specified a simple integer value 2. In general, the expression can an arbitrary vector.
184184
185185
Using 'MapAt' with 'Function[0]', we can zero a value or values in a vector:
186186
187187
>> MapAt[0&, {{1, 1}, {1, 1}}, {2, 1}]
188188
= {{1, 1}, {0, 1}}
189189
190-
When the dimension of the replacment expression is less than the vector, \
190+
When the dimension of the replacement expression is less than the vector, \
191191
that element's dimension changes:
192192
193193
>> MapAt[0&, {{0, 1}, {1, 0}}, 2]
@@ -396,7 +396,7 @@ class Scan(Builtin):
396396
<dt>'Scan[$f$, $expr$]'
397397
<dd>applies $f$ to each element of $expr$ and returns 'Null'.
398398
399-
<dt>'Scan[$f$, $expr$, $levelspec$]
399+
<dt>'Scan[$f$, $expr$, $levelspec$]'
400400
<dd>applies $f$ to each level specified by $levelspec$ of $expr$.
401401
</dl>
402402

mathics/builtin/testing_expressions/equality_inequality.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ class Between(Builtin):
349349
<dt>'Between'[$x$, {$min$, $max$}]
350350
<dd>equivalent to $min$ <= $x$ <= $max$.
351351
<dt>'Between[$x$, { {$min1$, $max1$}, {$min2$, $max2$}, ...]'
352-
<dd>equivalent to $min1$ <= $x$ <= $max1$' || $min2$ <= $x$ <= $max2$ ...
352+
<dd>equivalent to $min1$ <= $x$ <= $max1$ || $min2$ <= $x$ <= $max2$ ...
353353
<dt>'Between[$range$]'
354354
<dd>operator form that yields 'Between'[$x$, $range$] when applied to expression $x$.
355355
</dl>

mathics/builtin/trace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class Stacktrace(_TraceBase):
153153
154154
<dl>
155155
<dt>'Stacktrace[]'
156-
<dd>Print Mathics3 stack trace of evalutations leading to this point
156+
<dd>Print Mathics3 stack trace of evaluations leading to this point
157157
</dl>
158158
159159
To show the Mathics3 evaluation stack at the \

mathics/core/builtin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ class IterationFunction(Builtin, ABC):
933933
allow_loopcontrol = False
934934
throw_iterb = True
935935

936-
def get_result(self, elements) -> ListExpression:
936+
def get_result(self, elements) -> Expression:
937937
raise NotImplementedError
938938

939939
def eval_symbol(self, expr, iterator, evaluation):

0 commit comments

Comments
 (0)