Skip to content

Conversation

harshkasat
Copy link
Contributor

@harshkasat harshkasat commented Jan 1, 2024

References to other Issues or PRs

Fixes #25965

Brief description of what is fixed or changed

What we have done in the codebase

  • Fix Integer ceiling(RootOf)
  • Testcase

Other comments

Release Notes

  • functions
    • I made a change in the ceiling as mentioned in the issue

@sympy-bot
Copy link

sympy-bot commented Jan 1, 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:

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

#### Brief description of what is fixed or changed
What we have done in the codebase
- [x] Fix Integer ceiling(RootOf)
- [x] Testcase 

#### 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 -->
* functions
   * I made a change in the ceiling as [mentioned ](https://github.com/sympy/sympy/issues/25965#issuecomment-1873359863) in the issue
<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

Comment on lines 399 to 400
s = ImageSet(Lambda(n, n + (CRootOf(x**5 - x**2 + 1, 0))), Integers)
assert s.intersect(Interval(-10, 10)) == {-9 + CRootOf(x**5 - x**2 + 1, 0), -8 + CRootOf(x**5 - x**2 + 1, 0), -7 + CRootOf(x**5 - x**2 + 1, 0), -6 + CRootOf(x**5 - x**2 + 1, 0), -5 + CRootOf(x**5 - x**2 + 1, 0), -4 + CRootOf(x**5 - x**2 + 1, 0), -3 + CRootOf(x**5 - x**2 + 1, 0), -2 + CRootOf(x**5 - x**2 + 1, 0), -1 + CRootOf(x**5 - x**2 + 1, 0), CRootOf(x**5 - x**2 + 1, 0) + 1, CRootOf(x**5 - x**2 + 1, 0) + 2, CRootOf(x**5 - x**2 + 1, 0) + 3, CRootOf(x**5 - x**2 + 1, 0) + 4, CRootOf(x**5 - x**2 + 1, 0) + 5, CRootOf(x**5 - x**2 + 1, 0) + 6, CRootOf(x**5 - x**2 + 1, 0) + 7, CRootOf(x**5 - x**2 + 1, 0) + 8, CRootOf(x**5 - x**2 + 1, 0) + 9, CRootOf(x**5 - x**2 + 1, 0) + 10, CRootOf(x**5 - x**2 + 1, 0)}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Long lines should be wrapped. See PEP 8.

@@ -390,6 +395,10 @@ def test_ceiling():
assert (ceiling(y) < n) == (y <= n - 1)
assert (ceiling(y) > n) == (y > n)

assert ceiling(RootOf(x**5-x**2+1,0)) == 0
Copy link
Collaborator

Choose a reason for hiding this comment

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

There should also be a test for floor. It would better to pick an example where the result is something other than zero.

Copy link

github-actions bot commented Jan 1, 2024

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 [a00718ba]    | After [c81c8169]    |   Ratio | Benchmark (Parameter)                                                |
|----------|----------------------|---------------------|---------|----------------------------------------------------------------------|
| -        | 70.2±0.6ms           | 45.3±0.3ms          |    0.64 | integrate.TimeIntegrationRisch02.time_doit(10)                       |
| -        | 68.5±1ms             | 43.8±0.4ms          |    0.64 | integrate.TimeIntegrationRisch02.time_doit_risch(10)                 |
| +        | 19.2±0.5μs           | 29.8±0.2μs          |    1.55 | integrate.TimeIntegrationRisch03.time_doit(1)                        |
| -        | 5.36±0.03ms          | 2.86±0.03ms         |    0.53 | logic.LogicSuite.time_load_file                                      |
| -        | 72.2±0.6ms           | 28.4±0.1ms          |    0.39 | polys.TimeGCD_GaussInt.time_op(1, 'dense')                           |
| -        | 72.7±0.6ms           | 28.8±0.2ms          |    0.4  | polys.TimeGCD_GaussInt.time_op(1, 'sparse')                          |
| -        | 253±0.6ms            | 125±0.8ms           |    0.49 | polys.TimeGCD_GaussInt.time_op(2, 'dense')                           |
| -        | 254±0.9ms            | 125±0.5ms           |    0.49 | polys.TimeGCD_GaussInt.time_op(2, 'sparse')                          |
| -        | 655±2ms              | 370±2ms             |    0.56 | polys.TimeGCD_GaussInt.time_op(3, 'dense')                           |
| -        | 654±2ms              | 371±2ms             |    0.57 | polys.TimeGCD_GaussInt.time_op(3, 'sparse')                          |
| -        | 493±4μs              | 288±1μs             |    0.58 | polys.TimeGCD_LinearDenseQuadraticGCD.time_op(1, 'dense')            |
| -        | 1.77±0.01ms          | 1.06±0.01ms         |    0.6  | polys.TimeGCD_LinearDenseQuadraticGCD.time_op(2, 'dense')            |
| -        | 5.79±0.03ms          | 3.09±0.02ms         |    0.53 | polys.TimeGCD_LinearDenseQuadraticGCD.time_op(3, 'dense')            |
| -        | 443±4μs              | 232±2μs             |    0.52 | polys.TimeGCD_QuadraticNonMonicGCD.time_op(1, 'dense')               |
| -        | 1.47±0.01ms          | 682±3μs             |    0.46 | polys.TimeGCD_QuadraticNonMonicGCD.time_op(2, 'dense')               |
| -        | 4.88±0.01ms          | 1.66±0.01ms         |    0.34 | polys.TimeGCD_QuadraticNonMonicGCD.time_op(3, 'dense')               |
| -        | 372±1μs              | 204±0.9μs           |    0.55 | polys.TimeGCD_SparseGCDHighDegree.time_op(1, 'dense')                |
| -        | 2.45±0.01ms          | 1.25±0.02ms         |    0.51 | polys.TimeGCD_SparseGCDHighDegree.time_op(3, 'dense')                |
| -        | 10.2±0.1ms           | 4.41±0.03ms         |    0.43 | polys.TimeGCD_SparseGCDHighDegree.time_op(5, 'dense')                |
| -        | 362±1μs              | 168±2μs             |    0.46 | polys.TimeGCD_SparseNonMonicQuadratic.time_op(1, 'dense')            |
| -        | 2.50±0.01ms          | 895±9μs             |    0.36 | polys.TimeGCD_SparseNonMonicQuadratic.time_op(3, 'dense')            |
| -        | 9.48±0.03ms          | 2.62±0.02ms         |    0.28 | polys.TimeGCD_SparseNonMonicQuadratic.time_op(5, 'dense')            |
| -        | 1.01±0.01ms          | 425±4μs             |    0.42 | polys.TimePREM_LinearDenseQuadraticGCD.time_op(3, 'dense')           |
| -        | 1.76±0.02ms          | 500±2μs             |    0.28 | polys.TimePREM_LinearDenseQuadraticGCD.time_op(3, 'sparse')          |
| -        | 5.82±0.06ms          | 1.81±0.03ms         |    0.31 | polys.TimePREM_LinearDenseQuadraticGCD.time_op(5, 'dense')           |
| -        | 8.41±0.05ms          | 1.51±0.01ms         |    0.18 | polys.TimePREM_LinearDenseQuadraticGCD.time_op(5, 'sparse')          |
| -        | 285±0.8μs            | 65.4±0.4μs          |    0.23 | polys.TimePREM_QuadraticNonMonicGCD.time_op(1, 'sparse')             |
| -        | 3.43±0.04ms          | 400±3μs             |    0.12 | polys.TimePREM_QuadraticNonMonicGCD.time_op(3, 'dense')              |
| -        | 3.93±0.02ms          | 282±2μs             |    0.07 | polys.TimePREM_QuadraticNonMonicGCD.time_op(3, 'sparse')             |
| -        | 6.87±0.04ms          | 1.24±0.01ms         |    0.18 | polys.TimePREM_QuadraticNonMonicGCD.time_op(5, 'dense')              |
| -        | 8.65±0.06ms          | 839±3μs             |    0.1  | polys.TimePREM_QuadraticNonMonicGCD.time_op(5, 'sparse')             |
| -        | 4.98±0.02ms          | 2.97±0.01ms         |    0.6  | polys.TimeSUBRESULTANTS_LinearDenseQuadraticGCD.time_op(2, 'sparse') |
| -        | 12.2±0.08ms          | 6.59±0.02ms         |    0.54 | polys.TimeSUBRESULTANTS_LinearDenseQuadraticGCD.time_op(3, 'dense')  |
| -        | 22.1±0.1ms           | 9.08±0.02ms         |    0.41 | polys.TimeSUBRESULTANTS_LinearDenseQuadraticGCD.time_op(3, 'sparse') |
| -        | 5.22±0.04ms          | 873±4μs             |    0.17 | polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(1, 'sparse')    |
| -        | 12.7±0.1ms           | 7.13±0.08ms         |    0.56 | polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(2, 'sparse')    |
| -        | 101±1ms              | 26.0±0.09ms         |    0.26 | polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(3, 'dense')     |
| -        | 166±0.9ms            | 54.3±0.2ms          |    0.33 | polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(3, 'sparse')    |
| -        | 176±0.4μs            | 113±1μs             |    0.64 | polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(1, 'dense')      |
| -        | 351±2μs              | 217±0.6μs           |    0.62 | polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(1, 'sparse')     |
| -        | 4.25±0.01ms          | 845±5μs             |    0.2  | polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(3, 'dense')      |
| -        | 5.27±0.01ms          | 383±0.8μs           |    0.07 | polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(3, 'sparse')     |
| -        | 19.9±0.3ms           | 2.83±0ms            |    0.14 | polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(5, 'dense')      |
| -        | 22.8±0.2ms           | 625±2μs             |    0.03 | polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(5, 'sparse')     |
| -        | 474±3μs              | 134±0.7μs           |    0.28 | polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(1, 'sparse') |
| -        | 4.69±0.04ms          | 615±2μs             |    0.13 | polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(3, 'dense')  |
| -        | 5.28±0.03ms          | 137±1μs             |    0.03 | polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(3, 'sparse') |
| -        | 13.1±0.1ms           | 1.28±0ms            |    0.1  | polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(5, 'dense')  |
| -        | 13.9±0.08ms          | 142±1μs             |    0.01 | polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(5, 'sparse') |
| -        | 133±0.7μs            | 76.6±1μs            |    0.58 | solve.TimeMatrixOperations.time_rref(3, 0)                           |
| -        | 253±1μs              | 88.3±0.4μs          |    0.35 | solve.TimeMatrixOperations.time_rref(4, 0)                           |
| -        | 24.4±0.2ms           | 10.3±0.02ms         |    0.42 | 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).

Comment on lines 402 to 411
assert s.intersect(Interval(-10, 10)) == {-9 + CRootOf(x**5 - x**2 + 1, 0),
-8 + CRootOf(x**5 - x**2 + 1, 0), -7 + CRootOf(x**5 - x**2 + 1, 0), -6 +
CRootOf(x**5 - x**2 + 1, 0), -5 + CRootOf(x**5 - x**2 + 1, 0), -4 +
CRootOf(x**5 - x**2 + 1, 0), -3 + CRootOf(x**5 - x**2 + 1, 0), -2 +
CRootOf(x**5 - x**2 + 1, 0), -1 + CRootOf(x**5 - x**2 + 1, 0), CRootOf(x**5 - x**2 + 1, 0) + 1,
CRootOf(x**5 - x**2 + 1, 0) + 2, CRootOf(x**5 - x**2 + 1, 0) + 3,
CRootOf(x**5 - x**2 + 1, 0) + 4, CRootOf(x**5 - x**2 + 1, 0) + 5,
CRootOf(x**5 - x**2 + 1, 0) + 6, CRootOf(x**5 - x**2 + 1, 0) + 7,
CRootOf(x**5 - x**2 + 1, 0) + 8, CRootOf(x**5 - x**2 + 1, 0) + 9,
CRootOf(x**5 - x**2 + 1, 0) + 10, CRootOf(x**5 - x**2 + 1, 0)}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Take some time to consider how to format your code for readability. It is not hard to format this in a nicer way e.g.:

assert s.intersect(Interval(-10, 10)) == {
    -9 + CRootOf(x**5 - x**2 + 1, 0),
    -8 + CRootOf(x**5 - x**2 + 1, 0),
    ...
}

I would just use a comprehension though:

r = CRootOf(x**5 - x**2 + 1, 0)
assert s.intersect(Interval(-10, 10)) == {i + r for i in range(-9, 11)}

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.

ceiling(CRootOf()) not implemented, leads to exception in Range
3 participants