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

align divmod with Python behavior #25648

Merged
merged 1 commit into from Sep 8, 2023
Merged

Conversation

smichr
Copy link
Member

@smichr smichr commented Sep 8, 2023

References to other Issues or PRs

Brief description of what is fixed or changed

>>> divmod(S(4), S(-2.0))
(-3, -2.0) <----- should be (-2, -0.0)

Other comments

Release Notes

  • core
    • divmod(a,b) now gives i, r with abs(r) < abs(b) when a*b is a negative float, e.g. divmod(S(4), S(-2.0)) -> (-2, 0.0)

@sympy-bot
Copy link

sympy-bot commented Sep 8, 2023

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:

  • core
    • divmod(a,b) now gives i, r with abs(r) < abs(b) when a*b is a negative float, e.g. divmod(S(4), S(-2.0)) -> (-2, 0.0) (#25648 by @smichr)

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


#### Brief description of what is fixed or changed
```python
>>> divmod(S(4), S(-2.0))
(-3, -2.0) <----- should be (-2, -0.0)
```


#### 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 -->
* core
    * divmod(a,b) now gives i, r with abs(r) < abs(b) when a*b is a negative float, e.g. `divmod(S(4), S(-2.0)) -> (-2, 0.0)`
<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@github-actions
Copy link

github-actions bot commented Sep 8, 2023

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)

| Change   | Before [8059df73] <sympy-1.12^0>   | After [baae1d96]    |   Ratio | Benchmark (Parameter)                                                |
|----------|------------------------------------|---------------------|---------|----------------------------------------------------------------------|
| -        | 103±2ms                            | 67.2±0.6ms          |    0.65 | integrate.TimeIntegrationRisch02.time_doit(10)                       |
| -        | 101±2ms                            | 66.3±0.3ms          |    0.66 | integrate.TimeIntegrationRisch02.time_doit_risch(10)                 |
| +        | 25.6±0.05μs                        | 45.7±0.2μs          |    1.79 | integrate.TimeIntegrationRisch03.time_doit(1)                        |
| -        | 8.23±0.01ms                        | 4.47±0.02ms         |    0.54 | logic.LogicSuite.time_load_file                                      |
| -        | 2.45±0ms                           | 786±2μs             |    0.32 | polys.TimePREM_LinearDenseQuadraticGCD.time_op(3, 'sparse')          |
| -        | 12.0±0.02ms                        | 2.35±0ms            |    0.2  | polys.TimePREM_LinearDenseQuadraticGCD.time_op(5, 'sparse')          |
| -        | 438±0.5μs                          | 97.7±0.4μs          |    0.22 | polys.TimePREM_QuadraticNonMonicGCD.time_op(1, 'sparse')             |
| -        | 5.58±0.02ms                        | 434±0.8μs           |    0.08 | polys.TimePREM_QuadraticNonMonicGCD.time_op(3, 'sparse')             |
| -        | 12.2±0.03ms                        | 1.31±0ms            |    0.11 | polys.TimePREM_QuadraticNonMonicGCD.time_op(5, 'sparse')             |
| -        | 7.37±0.02ms                        | 4.73±0.02ms         |    0.64 | polys.TimeSUBRESULTANTS_LinearDenseQuadraticGCD.time_op(2, 'sparse') |
| -        | 32.0±0.06ms                        | 14.4±0.03ms         |    0.45 | polys.TimeSUBRESULTANTS_LinearDenseQuadraticGCD.time_op(3, 'sparse') |
| -        | 8.32±0.02ms                        | 1.40±0ms            |    0.17 | polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(1, 'sparse')    |
| -        | 19.2±0.04ms                        | 11.1±0.03ms         |    0.58 | polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(2, 'sparse')    |
| -        | 246±0.6ms                          | 84.4±0.05ms         |    0.34 | polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(3, 'sparse')    |
| -        | 7.36±0.02ms                        | 643±5μs             |    0.09 | polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(3, 'sparse')     |
| -        | 31.7±0.1ms                         | 1.02±0ms            |    0.03 | polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(5, 'sparse')     |
| -        | 726±1μs                            | 237±1μs             |    0.33 | polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(1, 'sparse') |
| -        | 7.49±0.01ms                        | 241±2μs             |    0.03 | polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(3, 'sparse') |
| -        | 19.6±0.07ms                        | 245±0.9μs           |    0.01 | polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(5, 'sparse') |
| -        | 191±0.3μs                          | 106±0.3μs           |    0.55 | solve.TimeMatrixOperations.time_rref(3, 0)                           |
| -        | 365±0.3μs                          | 129±0.9μs           |    0.35 | solve.TimeMatrixOperations.time_rref(4, 0)                           |
| -        | 37.5±0.1ms                         | 16.3±0.2ms          |    0.43 | solve.TimeSolveLinSys189x49.time_solve_lin_sys                       |

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

@oscarbenjamin
Copy link
Contributor

Release Notes

  • core

    • divmod(a,b) now gives i, r with abs(r) < abs(b) when a*b is a negative float, e.g. divmod(S(4), S(-2.0)) -> (2, 0.0)

Should this say (-2, 0.0)?

@oscarbenjamin
Copy link
Contributor

Should this say (-2, 0.0)?

I just corrected the release note

@oscarbenjamin
Copy link
Contributor

Looks good.

@oscarbenjamin oscarbenjamin merged commit fe95979 into sympy:master Sep 8, 2023
58 checks passed
@smichr smichr deleted the divmod branch September 11, 2023 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants