Skip to content

Negative, Positive, NonNegative, NonPositive: decide for Infinity and -Infinity - #1996

Open
tombouctou wants to merge 1 commit into
Mathics3:masterfrom
tombouctou:fix-sign-tests-infinity
Open

tombouctou wants to merge 1 commit into
Mathics3:masterfrom
tombouctou:fix-sign-tests-infinity

Conversation

@tombouctou

Copy link
Copy Markdown

Negative, Positive, NonNegative and NonPositive only had a rule for NumericQ arguments. Infinity is not NumericQ, so these tests stayed unevaluated on infinite values:

In[1]:= Negative[Infinity]
Out[1]= Negative[Infinity]      (* WMA: False *)

This matters for code such as And @@ Not /@ Negative /@ (2 {Infinity, i, j} - {i, j, 0}), which never decides.

This PR adds the values for DirectedInfinity[1] and DirectedInfinity[-1] to the four functions. ComplexInfinity and other directions stay unevaluated.

Tests: new cases in test/builtin/test_testing_expressions.py (test_numerical_properties) and a doctest in Negative.

🤖 Generated with Claude Code

… -Infinity

These tests only had a rule for NumericQ arguments, and Infinity is not
NumericQ, so Negative[Infinity] stayed unevaluated (WMA: False). Add the
values for DirectedInfinity[1] and DirectedInfinity[-1].

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant