Skip to content

Commit

Permalink
Remove duplication of "intnm" messages
Browse files Browse the repository at this point in the history
  • Loading branch information
rocky committed Oct 13, 2024
1 parent d3b283e commit d2c305c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
12 changes: 9 additions & 3 deletions mathics/builtin/atomic/numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@
import mpmath
import sympy

from mathics.core.atoms import Integer, Integer0, Integer10, MachineReal, Rational
from mathics.core.atoms import (
Integer,
Integer0,
Integer3,
Integer10,
MachineReal,
Rational,
)
from mathics.core.attributes import A_LISTABLE, A_PROTECTED
from mathics.core.builtin import Builtin, Predefined
from mathics.core.convert.python import from_python
Expand Down Expand Up @@ -421,7 +428,6 @@ class RealDigits(Builtin):
"realx": "The value `1` is not a real number.",
"ndig": "The number of digits to return cannot be determined.",
"rbase": "Base `1` is not a real number greater than 1.",
"intnm": "Non-negative machine-sized integer expected at position 3 in `1`.",
"intm": "Machine-sized integer expected at position 4 in `1`.",
}

Expand Down Expand Up @@ -590,7 +596,7 @@ def eval_with_base_and_length(self, n, b, length, evaluation, pos=None):
elements.append(from_python(pos))
expr = Expression(SymbolRealDigits, n, b, length, *elements)
if not (isinstance(length, Integer) and length.get_int_value() >= 0):
evaluation.message("RealDigits", "intnm", expr)
evaluation.message("RealDigits", "intnm", Integer3, expr)
return

return self.eval_with_base(
Expand Down
1 change: 0 additions & 1 deletion mathics/builtin/file_operations/file_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class FindList(Builtin):

messages = {
"strs": "String or non-empty list of strings expected at position `1` in `2`.",
"intnm": "Non-negative machine-sized integer expected at position `1` in `2`.",
}

options = {
Expand Down
5 changes: 1 addition & 4 deletions mathics/builtin/files_io/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# We use the below import for access to variables that may change
# at runtime.
import mathics.eval.files_io.files as io_files
from mathics.core.atoms import Integer, String, SymbolString
from mathics.core.atoms import Integer, Integer3, String, SymbolString
from mathics.core.attributes import A_PROTECTED, A_READ_PROTECTED
from mathics.core.builtin import (
BinaryOperator,
Expand Down Expand Up @@ -843,9 +843,6 @@ class Read(Builtin):
"readf": "`1` is not a valid format specification.",
"readn": "Invalid real number found when reading from `1`.",
"readt": "Invalid input found when reading `1` from `2`.",
"intnm": (
"Non-negative machine-sized integer expected at " "position 3 in `1`."
),
}

rules = {
Expand Down
5 changes: 2 additions & 3 deletions mathics/builtin/functional/apply_fns_to_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from typing import Iterable

from mathics.builtin.list.constructing import List
from mathics.core.atoms import Integer
from mathics.core.atoms import Integer, Integer3
from mathics.core.builtin import BinaryOperator, Builtin
from mathics.core.convert.expression import to_mathics_list
from mathics.core.evaluation import Evaluation
Expand Down Expand Up @@ -328,7 +328,6 @@ class MapThread(Builtin):

summary_text = "map a function across corresponding elements in multiple lists"
messages = {
"intnm": "Non-negative machine-sized integer expected at position `2` in `1`.",
"mptc": "Incompatible dimensions of objects at positions {2, `1`} and {2, `2`} of `3`; dimensions are `4` and `5`.",
"mptd": "Object `1` at position {2, `2`} in `3` has only `4` of required `5` dimensions.",
"list": "List expected at position `2` in `1`.",
Expand All @@ -350,7 +349,7 @@ def eval_n(self, f, expr, n, evaluation):
n = n.get_int_value()

if n is None or n < 0:
evaluation.message("MapThread", "intnm", full_expr, 3)
evaluation.message("MapThread", "intnm", Integer3, full_expr)
return

if expr.has_form("List", 0):
Expand Down
1 change: 1 addition & 0 deletions mathics/builtin/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ class General(Builtin):
"int": "Integer expected.",
"intp": "Positive integer expected.",
"intnn": "Non-negative integer expected.",
"intnm": "Non-negative machine-sized integer expected at position `1` in `2`.",
"iterb": "Iterator does not have appropriate bounds.",
"ivar": "`1` is not a valid variable.",
"level": ("Level specification `1` is not of the form n, " "{n}, or {m, n}."),
Expand Down
5 changes: 1 addition & 4 deletions mathics/builtin/string/charcodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,6 @@ class FromCharacterCode(Builtin):
"A character code, which should be a non-negative integer less "
"than 65536, is expected at position `2` in `1`."
),
"intnm": (
"Non-negative machine-sized integer expected at " "position `2` in `1`."
),
"utf8": "The given codes could not be decoded as utf-8.",
}
summary_text = "convert from a list of character codes to a string"
Expand Down Expand Up @@ -212,7 +209,7 @@ def convert_codepoint_list(li):
else:
pyn = n.get_int_value()
if not (isinstance(pyn, int) and pyn > 0 and pyn < sys.maxsize):
evaluation.message("FromCharacterCode", "intnm", exp, Integer1)
evaluation.message("FromCharacterCode", "intnm", Integer1, exp)
return
return String(convert_codepoint_list([n]))
except _InvalidCodepointError:
Expand Down

0 comments on commit d2c305c

Please sign in to comment.