Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@utam-1
Copy link
Contributor

@utam-1 utam-1 commented Oct 23, 2025

Based on feedback, test cases are added in test_parser_mathematica_tokenizer, testing that S-expression equivalent is correctly parsed before converting to a SymPy expression.

References to other Issues or PRs

Follow-up to #28492

Brief description of what is fixed or changed

Added tests for Not operator(!) inside the aforementioned test block.

Other comments

Release Notes

NO ENTRY

Based on feedback, test cases are added in the mentioned block testing that S-expression equivalent is correctly parsed before converting to a SymPy expression.
@sympy-bot
Copy link

Hi, I am the SymPy bot. I'm here to help you write a release notes entry. Please read the guide on how to write release notes.

  • No release notes entry will be added for this pull request.
Click here to see the pull request description that was parsed.
Based on feedback, test cases are added in `test_parser_mathematica_tokenizer`, testing that S-expression equivalent is correctly parsed before converting to a SymPy expression.

<!-- Your title above should be a short description of what
was changed. Do not include the issue number in the title. -->

#### References to other Issues or PRs
<!-- If this pull request fixes an issue, write "Fixes #NNNN" in that exact
format, e.g. "Fixes #1234" (see
https://tinyurl.com/auto-closing for more information). Also, please
write a comment on that issue linking back to this pull request once it is
open. -->
Follow-up to #28492 

#### Brief description of what is fixed or changed
Added tests for Not operator(!) inside the aforementioned test block.

#### Other comments


#### Release Notes

<!-- Write the release notes for this release below between the BEGIN and END
statements. The basic format is a bulleted list with the name of the subpackage
and the release note for this PR. For example:

* solvers
  * Added a new solver for logarithmic equations.

* functions
  * Fixed a bug with log of integers. Formerly, `log(-x)` incorrectly gave `-log(x)`.

* physics.units
  * Corrected a semantical error in the conversion between volt and statvolt which
    reported the volt as being larger than the statvolt.

or if no release note(s) should be included use:

NO ENTRY

See https://github.com/sympy/sympy/wiki/Writing-Release-Notes for more
information on how to write release notes. The bot will check your release
notes automatically to see if they are formatted correctly. -->

<!-- BEGIN RELEASE NOTES -->
NO ENTRY
<!-- END RELEASE NOTES -->

@utam-1 utam-1 marked this pull request as ready for review October 23, 2025 12:59
@utam-1
Copy link
Contributor Author

utam-1 commented Oct 23, 2025

@Upabjojr I have added the test cases based on feedback, do let me know if any further improvements are needed.

# Combination of Not with And/Or
assert chain("!x && y") == ["And", ["Not", "x"], "y"]
assert chain("x || !y") == ["Or", "x", ["Not", "y"]]
assert chain("!x || !y") == ["Or", ["Not", "x"], ["Not", "y"]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens with "x!y" ?

Copy link
Contributor Author

@utam-1 utam-1 Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this and parse_mathematica returns y*factorial(x). I believe that this should be the expected behavior when such expressions are encountered. I have also added further test cases to document this behavior.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does Wolfram Mathematica return the same? Was just wondering whether prefix or postfix has a higher precedence with ! in Mathematica.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested x!y in https://www.wolframalpha.com/ and it is returning yΓx+1. It does return the same I believe (with Γx+1 = x!).

@Upabjojr Upabjojr merged commit 760ceac into sympy:master Oct 25, 2025
45 checks passed
@Upabjojr
Copy link
Contributor

Thank you for your contribution!

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.

3 participants