Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a wrong behavior (parse of power negative arguments) of function parse_mathematica. #24224

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

TheDeveloperDino
Copy link

References to other Issues or PRs

Fixes #24150

Brief description of what is fixed or changed

Fixed wrong behavior of function parse_mathematica in module parsing.mathematica.
In function parse changed statement _mathematica_op_precedence as follow:

Rule of power transferred before rule of prefix operators.

#rule of power transferred before rule of prefix operators
(INFIX, RIGHT, {"^": "Power"}),
(PREFIX, None, {"-": lambda x: MathematicaParser._get_neg(x),
                "+": lambda x: x}),

Example of result behavior:

>>> parse_mathematica("2^-10*x")
x/1024

Other comments

Release Notes

  • parsing
    • functions
      • Fixed a wrong behavior (parse of power negative arguments) of function parse_mathematica.
      • Make parse_mathematica("2^-10*x") give x/1024 instead of 2**(-10*x).

Upload pull_request.md file.
Fixed a wrong behavior (parse of power negative arguments) of function parse_mathematica.
@sympy-bot
Copy link

sympy-bot commented Nov 6, 2022

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

Your release notes are in good order.

Here is what the release notes will look like:

This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.12.

Click here to see the pull request description that was parsed.
<!-- 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
Fixes #24150
<!-- 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. -->


#### Brief description of what is fixed or changed
Fixed wrong behavior of function **parse_mathematica** in module ***parsing.mathematica***.
In function parse changed statement ***_mathematica_op_precedence*** as follow:

*Rule of power* transferred **before** *rule of prefix operators*.
```python
#rule of power transferred before rule of prefix operators
(INFIX, RIGHT, {"^": "Power"}),
(PREFIX, None, {"-": lambda x: MathematicaParser._get_neg(x),
                "+": lambda x: x}),
```

Example of result behavior:
```python
>>> parse_mathematica("2^-10*x")
x/1024
```

#### 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.

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 -->

* parsing
  * functions
    * Fixed a wrong behavior (parse of power negative arguments) of function parse_mathematica.
    * Make `parse_mathematica("2^-10*x")` give `x/1024` instead of `2**(-10*x)`.

<!-- END RELEASE NOTES -->

@sympy-bot
Copy link

sympy-bot commented Nov 6, 2022

🟠

Hi, I am the SymPy bot (v169). I've noticed that some of your commits add or delete files. Since this is sometimes done unintentionally, I wanted to alert you about it.

This is an experimental feature of SymPy Bot. If you have any feedback on it, please comment at sympy/sympy-bot#75.

The following commits add new files:

  • 1170fc9:
    • PULL_REQUEST.md
  • 07a54c9:
    • coverage-dino.py
    • profile_task-dino.py

The following commits delete files:

If these files were added/deleted on purpose, you can ignore this message.

@oscarbenjamin
Copy link
Contributor

The authors test has failed. A line should be added in the .mailmap file:

This author is not included in the .mailmap file:
TheDeveloperDino <92088583+TheDeveloperDino@users.noreply.github.com>

The .mailmap file needs to be updated because there are commits with
unrecognised author/email metadata.

@oscarbenjamin
Copy link
Contributor

A test should be added for the changed behaviour.

@oscarbenjamin
Copy link
Contributor

The commits will need to be squashed because one commit removes a file and another adds it back again.

@oscarbenjamin
Copy link
Contributor

I'm going to mark this PR as a draft. Feel free to change it to ready for review once the issues above are addressed.

@oscarbenjamin oscarbenjamin marked this pull request as draft November 24, 2022 18:26
@samithkavishke
Copy link
Contributor

Is this PR still inprogress? there are redundant files that you have attached with the PR.

@samithkavishke
Copy link
Contributor

@TheDeveloperDino I can work on this, if you are not developing this..

Copy link
Contributor

Choose a reason for hiding this comment

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

This file is redundant, I guess you have added a testing file with your PR.

print("Error test: " + str(result[2]))


#def parse(self, s):
Copy link
Contributor

Choose a reason for hiding this comment

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

It is better if you remove this commented code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: parse_mathematica uses wrong operation priority with negative numbers in the exponent
4 participants