Skip to content

Commit 2d9b1a9

Browse files
authored
Merge pull request #707 from Mathics3/misc-lint
Ring in 2023!
2 parents 1456979 + 6d4d0a0 commit 2d9b1a9

File tree

7 files changed

+40
-40
lines changed

7 files changed

+40
-40
lines changed

mathics/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858

5959

6060
license_string = """\
61-
Copyright (C) 2011-2022 The Mathics Team.
61+
Copyright (C) 2011-2023 The Mathics Team.
6262
This program comes with ABSOLUTELY NO WARRANTY.
6363
This is free software, and you are welcome to redistribute it
6464
under certain conditions.

mathics/builtin/assignments/clear.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def do_clear(self, definition):
8888
definition.formatvalues = {}
8989
definition.nvalues = []
9090

91-
def apply(self, symbols, evaluation):
91+
def eval(self, symbols, evaluation):
9292
"%(name)s[symbols___]"
9393
if isinstance(symbols, Symbol):
9494
symbols = [symbols]
@@ -286,7 +286,7 @@ class Unset(PostfixOperator):
286286
precedence = 670
287287
summary_text = "unset a value of the LHS"
288288

289-
def apply(self, expr, evaluation):
289+
def eval(self, expr, evaluation):
290290
"Unset[expr_]"
291291

292292
head = expr.get_head()

mathics/builtin/atomic/atomic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class Head(Builtin):
7979

8080
summary_text = "find the head of any expression, including an atom"
8181

82-
def apply(self, expr, evaluation):
82+
def eval(self, expr, evaluation):
8383
"Head[expr_]"
8484

8585
return expr.get_head()

mathics/builtin/atomic/numbers.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ class Accuracy(Builtin):
201201

202202
summary_text = "find the accuracy of a number"
203203

204-
def apply(self, z, evaluation):
204+
def eval(self, z, evaluation):
205205
"Accuracy[z_]"
206206
if isinstance(z, Real):
207207
if z.is_zero:
@@ -211,8 +211,8 @@ def apply(self, z, evaluation):
211211
return MachineReal(dps(z.get_precision()) - log10_z)
212212

213213
if isinstance(z, Complex):
214-
acc_real = self.apply(z.real, evaluation)
215-
acc_imag = self.apply(z.imag, evaluation)
214+
acc_real = self.eval(z.real, evaluation)
215+
acc_imag = self.eval(z.imag, evaluation)
216216
if acc_real is SymbolInfinity:
217217
return acc_imag
218218
if acc_imag is SymbolInfinity:
@@ -222,7 +222,7 @@ def apply(self, z, evaluation):
222222
if isinstance(z, Expression):
223223
result = None
224224
for element in z.elements:
225-
candidate = self.apply(element, evaluation)
225+
candidate = self.eval(element, evaluation)
226226
if isinstance(candidate, Real):
227227
candidate_f = candidate.to_python()
228228
if result is None or candidate_f < result:
@@ -296,7 +296,7 @@ class IntegerExponent(Builtin):
296296

297297
summary_text = "number of trailing 0s in a given base"
298298

299-
def apply_two_arg_integers(self, n: Integer, b: Integer, evaluation):
299+
def eval_two_arg_integers(self, n: Integer, b: Integer, evaluation):
300300
"IntegerExponent[n_Integer, b_Integer]"
301301

302302
py_n, py_b = n.value, b.value
@@ -313,7 +313,7 @@ def apply_two_arg_integers(self, n: Integer, b: Integer, evaluation):
313313

314314
# FIXME: If WMA supports things other than Integers, the below code might
315315
# be useful as a starting point.
316-
# def apply(self, n: Integer, b: Integer, evaluation):
316+
# def eval(self, n: Integer, b: Integer, evaluation):
317317
# "IntegerExponent[n_Integer, b_Integer]"
318318

319319
# py_n, py_b = n.to_python(), b.to_python()
@@ -386,7 +386,7 @@ class IntegerLength(Builtin):
386386

387387
summary_text = "total number of digits in any base"
388388

389-
def apply(self, n, b, evaluation):
389+
def eval(self, n, b, evaluation):
390390
"IntegerLength[n_, b_]"
391391

392392
n, b = n.get_int_value(), b.get_int_value()
@@ -587,17 +587,17 @@ class RealDigits(Builtin):
587587

588588
summary_text = "digits of a real number"
589589

590-
def apply_complex(self, n, var, evaluation):
590+
def eval_complex(self, n, var, evaluation):
591591
"%(name)s[n_Complex, var___]"
592592
return evaluation.message("RealDigits", "realx", n)
593593

594-
def apply_rational_with_base(self, n, b, evaluation):
594+
def eval_rational_with_base(self, n, b, evaluation):
595595
"%(name)s[n_Rational, b_Integer]"
596596
# expr = Expression(SymbolRealDigits, n)
597597
py_n = abs(n.value)
598598
py_b = b.value
599599
if check_finite_decimal(n.denominator().get_int_value()) and not py_b % 2:
600-
return self.apply_with_base(n, b, evaluation)
600+
return self.eval_with_base(n, b, evaluation)
601601
else:
602602
exp = int(mpmath.ceil(mpmath.log(py_n, py_b)))
603603
(head, tails) = convert_repeating_decimal(
@@ -612,12 +612,12 @@ def apply_rational_with_base(self, n, b, evaluation):
612612
list_expr = ListExpression(*elements)
613613
return ListExpression(list_expr, Integer(exp))
614614

615-
def apply_rational_without_base(self, n, evaluation):
615+
def eval_rational_without_base(self, n, evaluation):
616616
"%(name)s[n_Rational]"
617617

618-
return self.apply_rational_with_base(n, Integer(10), evaluation)
618+
return self.eval_rational_with_base(n, Integer(10), evaluation)
619619

620-
def apply(self, n, evaluation):
620+
def eval(self, n, evaluation):
621621
"%(name)s[n_]"
622622

623623
# Handling the testcases that throw the error message and return the
@@ -626,9 +626,9 @@ def apply(self, n, evaluation):
626626
return evaluation.message("RealDigits", "ndig", n)
627627

628628
if n.is_numeric(evaluation):
629-
return self.apply_with_base(n, from_python(10), evaluation)
629+
return self.eval_with_base(n, from_python(10), evaluation)
630630

631-
def apply_with_base(self, n, b, evaluation, nr_elements=None, pos=None):
631+
def eval_with_base(self, n, b, evaluation, nr_elements=None, pos=None):
632632
"%(name)s[n_?NumericQ, b_Integer]"
633633

634634
expr = Expression(SymbolRealDigits, n)
@@ -739,7 +739,7 @@ def apply_with_base(self, n, b, evaluation, nr_elements=None, pos=None):
739739
list_expr = ListExpression(*elements)
740740
return ListExpression(list_expr, Integer(exp))
741741

742-
def apply_with_base_and_length(self, n, b, length, evaluation, pos=None):
742+
def eval_with_base_and_length(self, n, b, length, evaluation, pos=None):
743743
"%(name)s[n_?NumericQ, b_Integer, length_]"
744744
elements = []
745745
if pos is not None:
@@ -748,18 +748,18 @@ def apply_with_base_and_length(self, n, b, length, evaluation, pos=None):
748748
if not (isinstance(length, Integer) and length.get_int_value() >= 0):
749749
return evaluation.message("RealDigits", "intnm", expr)
750750

751-
return self.apply_with_base(
751+
return self.eval_with_base(
752752
n, b, evaluation, nr_elements=length.get_int_value(), pos=pos
753753
)
754754

755-
def apply_with_base_length_and_precision(self, n, b, length, p, evaluation):
755+
def eval_with_base_length_and_precision(self, n, b, length, p, evaluation):
756756
"%(name)s[n_?NumericQ, b_Integer, length_, p_]"
757757
if not isinstance(p, Integer):
758758
return evaluation.message(
759759
"RealDigits", "intm", Expression(SymbolRealDigits, n, b, length, p)
760760
)
761761

762-
return self.apply_with_base_and_length(
762+
return self.eval_with_base_and_length(
763763
n, b, length, evaluation, pos=p.get_int_value()
764764
)
765765

@@ -1004,7 +1004,7 @@ class NumericQ(Builtin):
10041004
}
10051005
summary_text = "test whether an expression is a number"
10061006

1007-
def apply(self, expr, evaluation):
1007+
def eval(self, expr, evaluation):
10081008
"NumericQ[expr_]"
10091009
return from_bool(expr.is_numeric(evaluation))
10101010

@@ -1060,16 +1060,16 @@ class Precision(Builtin):
10601060

10611061
summary_text = "find the precision of a number"
10621062

1063-
def apply(self, z, evaluation):
1063+
def eval(self, z, evaluation):
10641064
"Precision[z_]"
10651065
if isinstance(z, Real):
10661066
if z.is_zero:
10671067
return MachineReal0
10681068
return MachineReal(dps(z.get_precision()))
10691069

10701070
if isinstance(z, Complex):
1071-
prec_real = self.apply(z.real, evaluation)
1072-
prec_imag = self.apply(z.imag, evaluation)
1071+
prec_real = self.eval(z.real, evaluation)
1072+
prec_imag = self.eval(z.imag, evaluation)
10731073
if prec_real is SymbolInfinity:
10741074
return prec_imag
10751075
if prec_imag is SymbolInfinity:
@@ -1080,7 +1080,7 @@ def apply(self, z, evaluation):
10801080
if isinstance(z, Expression):
10811081
result = None
10821082
for element in z.elements:
1083-
candidate = self.apply(element, evaluation)
1083+
candidate = self.eval(element, evaluation)
10841084
if isinstance(candidate, Real):
10851085
candidate_f = candidate.to_python()
10861086
if result is None or candidate_f < result:

mathics/builtin/base.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ class Builtin:
8383
Function application pattern matching
8484
-------------------------------------
8585
86-
Method names of a builtin-class that start with the word ``apply`` are evaluation methods that
86+
Method names of a builtin-class that start with the word ``eval`` are evaluation methods that
8787
will get called when the docstring of that method matches the expression to be evaluated.
8888
8989
For example:
9090
9191
```
92-
def apply(x, evaluation):
92+
def eval(x, evaluation):
9393
"F[x_Real]"
9494
return Expression(Symbol("G"), x*2)
9595
```
@@ -102,16 +102,16 @@ def apply(x, evaluation):
102102
``x``. The method must also have an evaluation parameter, and may
103103
have an optional `options` parameter.
104104
105-
If the ``apply*`` method returns ``None``, the replacement fails, and the expression keeps its original form.
105+
If the ``eval*`` method returns ``None``, the replacement fails, and the expression keeps its original form.
106106
107107
For rules including ``OptionsPattern``
108108
```
109-
def apply_with_options(x, evaluation, options):
109+
def eval_with_options(x, evaluation, options):
110110
'''F[x_Real, OptionsPattern[]]'''
111111
...
112112
```
113113
the options are stored as a dictionary in the last parameter. For example, if the rule is applied to ``F[x, Method->Automatic]``
114-
the expression is replaced by the output of ``apply_with_options(x, evaluation, {"System`Method": Symbol("Automatic")})
114+
the expression is replaced by the output of ``eval_with_options(x, evaluation, {"System`Method": Symbol("Automatic")})
115115
116116
The method ``contribute`` stores the definition of the ``Builtin`` ` `Symbol`` into a set of ``Definitions``. For example,
117117
@@ -417,7 +417,7 @@ def get_option(options, name, evaluation, pop=False):
417417
def _get_unavailable_function(self) -> Optional[Callable]:
418418
"""
419419
If some of the required libraries for a symbol are not available,
420-
returns a default function that override the ``apply_`` methods
420+
returns a default function that override the ``eval_`` methods
421421
of the class. Otherwise, returns ``None``.
422422
"""
423423

@@ -487,7 +487,7 @@ class AtomBuiltin(Builtin):
487487
have the Builtin function/variable/object properties.
488488
"""
489489

490-
# allows us to define apply functions, rules, messages, etc. for Atoms
490+
# allows us to define eval functions, rules, messages, etc. for Atoms
491491
# which are by default not in the definitions' contribution pipeline.
492492
# see Image[] for an example of this.
493493

@@ -613,7 +613,7 @@ def __init__(self, *args, **kwargs):
613613

614614

615615
class Test(Builtin):
616-
def apply(self, expr, evaluation) -> Optional[Symbol]:
616+
def eval(self, expr, evaluation) -> Optional[Symbol]:
617617
"%(name)s[expr_]"
618618
test_expr = self.test(expr)
619619
return None if test_expr is None else from_bool(bool(test_expr))
@@ -633,7 +633,7 @@ def eval(self, z, evaluation):
633633
# Note: we omit a docstring here, so as not to confuse
634634
# function signature collector ``contribute``.
635635

636-
# Generic apply method that uses the class sympy_name.
636+
# Generic eval method that uses the class sympy_name.
637637
# to call the corresponding sympy function. Arguments are
638638
# converted to python and the result is converted from sympy
639639
#

mathics/builtin/files_io/importexport.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1250,7 +1250,7 @@ class URLFetch(Builtin):
12501250
# = ...
12511251
"""
12521252

1253-
summary_text = "fetch data form an URL"
1253+
summary_text = "fetch data from a URL"
12541254
messages = {
12551255
"httperr": "`1` could not be retrieved; `2`.",
12561256
}

mathics/doc/latex/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: all clean doc doc-data latex texdoc
1+
.PHONY: all clean doc doc-data latex pdf texdoc
22

33
PYTHON ?= python
44
XETEX ?= xelatex
@@ -37,7 +37,7 @@ documentation.tex: $(DOC_TEX_DATA_PCL)
3737
$(PYTHON) ./doc2latex.py
3838

3939
#: Same as mathics.pdf
40-
latex: mathics.pdf
40+
pdf latex: mathics.pdf
4141

4242
#: Remove all auto-generated files
4343
clean:

0 commit comments

Comments
 (0)