Skip to content

Conversation

smichr
Copy link
Member

@smichr smichr commented Dec 14, 2021

References to other Issues or PRs

Brief description of what is fixed or changed

The following used to raise a ValueError:

>>> perfect_power(0)
False
>>> perfect_power(-9)
False
>>> perfect_power(-27)
(-3, 2)
>>> perfect_power(S.Half**3)
(1/2, 3)

Other comments

Release Notes

  • ntheory
    • perfect_power now only raises a ValueError for non-Rational input

@sympy-bot
Copy link

sympy-bot commented Dec 14, 2021

Hi, I am the SymPy bot (v162). 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:

  • ntheory
    • perfect_power now only raises a ValueError for non-Rational input (#22672 by @smichr)

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

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


#### Brief description of what is fixed or changed

The following used to raise a ValueError:
```python
>>> perfect_power(0)
False
>>> perfect_power(-9)
False
>>> perfect_power(-27)
(-3, 2)
>>> perfect_power(S.Half**3)
(1/2, 3)
```
#### 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 -->
* ntheory
    * `perfect_power` now only raises a ValueError for non-Rational input
<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@smichr smichr changed the title do not pass silently for perfect_power(1) perfect_power handles all Rationals Dec 14, 2021
@github-actions
Copy link

github-actions bot commented Dec 14, 2021

Benchmark results from GitHub Actions

Lower numbers are good, higher numbers are bad. A ratio less than 1
means a speed up and greater than 1 means a slowdown. Green lines
beginning with + are slowdowns (the PR is slower then master or
master is slower than the previous release). Red lines beginning
with - are speedups.

Significantly changed benchmark results (PR vs master)

Significantly changed benchmark results (master vs previous release)

       before           after         ratio
     [907895ac]       [7c0fa071]
-      5.06±0.01s          376±3ms     0.07  polygon.PolygonArbitraryPoint.time_bench01
+     3.95±0.05ms      6.78±0.07ms     1.72  solve.TimeMatrixOperations.time_det(4, 2)
+     3.97±0.03ms      6.76±0.04ms     1.70  solve.TimeMatrixOperations.time_det_bareiss(4, 2)
+      45.2±0.8ms         83.5±3ms     1.85  solve.TimeMatrixSolvePyDySlow.time_linsolve(1)
+      45.6±0.8ms         84.2±1ms     1.85  solve.TimeMatrixSolvePyDySlow.time_solve(1)

Full benchmark results can be found as artifacts in GitHub Actions
(click on checks at the top of the PR).


>>> perfect_power(Rational(1/2)**3)
(1/2, 3)
>>> perfect_power(Rational(-3/2)**3)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be e.g. Rational(-3, 2)?

Copy link
Member Author

Choose a reason for hiding this comment

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

denominators that are powers of 2 are exactly converted...but it is better practice to do as you show

>>> Rational(1/4)
1/4

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.

3 participants