Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions mathics/builtin/testing_expressions/numerical_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from mathics.core.convert.python import from_bool, from_python
from mathics.core.evaluation import Evaluation
from mathics.core.expression import Expression
from mathics.core.number import is_machine_precision, is_numeric
from mathics.core.number import get_int_value, is_machine_precision, is_numeric
from mathics.core.symbols import BooleanType, SymbolFalse, SymbolTrue
from mathics.core.systemsymbols import SymbolExpandAll, SymbolSimplify
from mathics.eval.arithmetic import test_zero_arithmetic_expr
Expand Down Expand Up @@ -99,7 +99,7 @@ class EvenQ(Test):
summary_text = "test whether elements are even numbers"

def test(self, n) -> bool:
value = n.int_value
value = get_int_value(n)
return value is not None and value % 2 == 0


Expand Down Expand Up @@ -408,7 +408,7 @@ class OddQ(Test):
summary_text = "test whether elements are odd numbers"

def test(self, n) -> bool:
value = n.int_value
value = get_int_value(n)
return value is not None and value % 2 != 0


Expand Down Expand Up @@ -557,7 +557,7 @@ class PrimeQ(SympyFunction):
def eval(self, n, evaluation: Evaluation) -> BooleanType:
"PrimeQ[n_]"

n = n.int_value
n = get_int_value(n)
if n is None:
return SymbolFalse

Expand Down
6 changes: 6 additions & 0 deletions test/builtin/test_testing_expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ def test_equality_inequality(str_expr, msgs, str_expected, fail_msg):
("Positive[Sin[{11, 14}]]", None, "{False, True}", None),
("PrimeQ[1]", None, "False", None),
("PrimeQ[2 ^ 255 - 1]", None, "False", None),
# Non-atomic arguments
("EvenQ[f[2]]", None, "False", None),
("OddQ[f[1]]", None, "False", None),
("PrimeQ[f[2]]", None, "False", None),
("MatchQ[f[2], _?EvenQ]", None, "False", None),
("Cases[{2, f[2], 3}, _?OddQ]", None, "{3}", None),
],
)
def test_numerical_properties(str_expr, msgs, str_expected, fail_msg):
Expand Down
Loading