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

Extra \cdot in LaTeX output for Mul between a numeric power and a polynomial with numeric coefficient since SymPy 1.10 #26540

Closed
wants to merge 1 commit into from

Conversation

krithikam321
Copy link

@krithikam321 krithikam321 commented Apr 25, 2024

References to other Issues or PRs

Fix #26430

Brief description of what is fixed or changed

fixed cdot issue by adding regex to take out the unnecessary cdots

Other comments

Release Notes

  • solvers

    • Fixed cdot issue by adding regex to take out the unnecessary cdots
  • functions

    • Fixed this bug by modifying the _print_Mul function

changes to fix sympy#26430 
line 500 are where the changes start
@sympy-bot
Copy link

sympy-bot commented Apr 25, 2024

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.

Your release notes are in good order.

Here is what the release notes will look like:

  • functions

  • solvers

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

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
<!-- 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. -->
Fix #26430 

#### Brief description of what is fixed or changed
fixed cdot issue by adding regex to take out the unnecessary cdots 

#### 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 -->
* solvers
  * Fixed cdot issue by adding regex to take out the unnecessary cdots 

* functions
  * Fixed this bug by modifying the _print_Mul function 
<!-- END RELEASE NOTES -->

@utensil
Copy link

utensil commented Apr 25, 2024

Thanks for the fix! ❤️

The minimal example in the issue could be added to the test cases.

@utensil
Copy link

utensil commented Apr 25, 2024

Also I wonder if it's possible to avoid adding \cdot in the first place, instead if taking it out afterwards. The former is easier to maintain.

Comment on lines +562 to +567
# Debug output before modification
# print("Original LaTeX:", _tex)
pattern = r'(\^\{[\d]+?\})\s*\\cdot\s*(\\left\(.+?\\right\))'
modified_latex = re.sub(pattern, r'\1 \2', _tex)
# print("Modified LaTeX:", modified_latex)
return modified_latex
Copy link
Contributor

Choose a reason for hiding this comment

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

The erroneous code should not be generated in the first place. Attempting to fix it afterwards with a regex is not the right fix.

Choose a reason for hiding this comment

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

@oscarbenjamin How do you propose to fix it properly?

Copy link
Contributor

Choose a reason for hiding this comment

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

You would need to find the source of the incorrect \cdot and fix it.

@oscarbenjamin
Copy link
Contributor

Closing after #26558

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