Skip to content

Conversation

oscargus
Copy link
Contributor

References to other Issues or PRs

Closes #18400

Brief description of what is fixed or changed

I started playing around with symbolic ranges and this seems to pass all the tests I ran at home.

If this seems like a way forward, I will add tests for #18400. (And try to fix any failing test...)

Other comments

Release Notes

  • sets
    • Better support for symbolic Range.

@oscargus oscargus added the sets label Aug 23, 2021
@sympy-bot
Copy link

sympy-bot commented Aug 23, 2021

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

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

Closes #18400

#### Brief description of what is fixed or changed
I started playing around with symbolic ranges and this seems to pass all the tests I ran at home.

If this seems like a way forward, I will add tests for #18400. (And try to fix any failing test...)

#### 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 -->
* sets
   * Better support for symbolic `Range`.
<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@oscargus
Copy link
Contributor Author

I understand this is by convention, but not really obvious anyway (and a bit annoying here):

In [29]: oo.is_positive
Out[29]: False

In [30]: oo > 0
Out[30]: True

@oscarbenjamin
Copy link
Collaborator

In [1]: oo.is_extended_positive
Out[1]: True

New docs explaining this:
https://docs.sympy.org/dev/guides/assumptions.html#predicates

@github-actions
Copy link

github-actions bot commented Aug 23, 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
     [ed9a550f]       [b4c1da60]
     <sympy-1.8^0>                 
-         913±4ms        125±0.8ms     0.14  dsolve.TimeDsolve01.time_dsolve
-      7.71±0.03s       4.01±0.01s     0.52  integrate.TimeIntegrationRisch02.time_doit(100)
-      7.75±0.01s       4.02±0.01s     0.52  integrate.TimeIntegrationRisch02.time_doit_risch(100)
-      65.9±0.9μs       25.4±0.3μs     0.39  matrices.TimeDiagonalEigenvals.time_eigenvals
-        78.1±2μs       51.0±0.8μs     0.65  matrices.TimeMatrixGetItem.time_ImmutableDenseMatrix_getitem
-      80.5±0.7μs       51.4±0.8μs     0.64  matrices.TimeMatrixGetItem.time_ImmutableSparseMatrix_getitem
-      79.1±0.5μs       51.0±0.5μs     0.64  matrices.TimeMatrixGetItem.time_MutableSparseMatrix_getitem
+        76.8±1μs          123±1μs     1.60  solve.TimeMatrixArithmetic.time_dense_add(10, 5)
+     10.4±0.07μs       17.0±0.2μs     1.63  solve.TimeMatrixArithmetic.time_dense_add(3, 0)
+      12.3±0.2μs       27.3±0.5μs     2.22  solve.TimeMatrixArithmetic.time_dense_add(3, 5)
+      18.1±0.3μs         34.8±1μs     1.92  solve.TimeMatrixArithmetic.time_dense_add(4, 5)
+      33.0±0.3μs       57.6±0.8μs     1.75  solve.TimeMatrixArithmetic.time_dense_add(6, 5)
-     1.10±0.01ms          226±3μs     0.21  solve.TimeMatrixArithmetic.time_dense_multiply(10, 0)
-      40.9±0.5μs       22.3±0.4μs     0.54  solve.TimeMatrixArithmetic.time_dense_multiply(3, 0)
+      64.7±0.3μs          117±2μs     1.80  solve.TimeMatrixArithmetic.time_dense_multiply(3, 5)
-        88.1±1μs       29.5±0.3μs     0.33  solve.TimeMatrixArithmetic.time_dense_multiply(4, 0)
-         263±2μs       63.9±0.3μs     0.24  solve.TimeMatrixArithmetic.time_dense_multiply(6, 0)
-      82.5±0.3μs       37.4±0.3μs     0.45  solve.TimeMatrixOperations.time_det(3, 0)
-       154±0.4μs       89.5±0.5μs     0.58  solve.TimeMatrixOperations.time_det(3, 2)
-         143±3μs       80.2±0.5μs     0.56  solve.TimeMatrixOperations.time_det(3, 5)
-      82.8±0.7μs       37.8±0.8μs     0.46  solve.TimeMatrixOperations.time_det_bareiss(3, 0)
-         154±1μs         91.5±1μs     0.59  solve.TimeMatrixOperations.time_det_bareiss(3, 2)
-         144±2μs       82.5±0.7μs     0.57  solve.TimeMatrixOperations.time_det_bareiss(3, 5)
-        82.6±1μs       37.5±0.3μs     0.45  solve.TimeMatrixOperations.time_det_berkowitz(3, 0)
-         153±2μs       89.6±0.9μs     0.58  solve.TimeMatrixOperations.time_det_berkowitz(3, 2)
-         145±1μs       80.3±0.7μs     0.55  solve.TimeMatrixOperations.time_det_berkowitz(3, 5)
+         684±5μs      1.09±0.01ms     1.59  solve.TimeMatrixOperations.time_det_berkowitz(4, 0)
+        856±10μs      1.55±0.02ms     1.81  solve.TimeMatrixOperations.time_det_berkowitz(4, 2)
+        883±10μs      1.65±0.02ms     1.86  solve.TimeMatrixOperations.time_det_berkowitz(4, 5)
+         250±8μs          412±3μs     1.64  solve.TimeMatrixOperations.time_rank(3, 0)
+         390±7μs          619±9μs     1.59  solve.TimeMatrixOperations.time_rank(4, 0)
+         113±2μs          172±2μs     1.52  solve.TimeMatrixOperations.time_rref(3, 0)
-      4.51±0.1ms      2.76±0.08ms     0.61  solve.TimeRationalSystem.time_linsolve(10)
+         908±8μs      1.36±0.02ms     1.50  solve.TimeSparseSystem.time_linear_eq_to_matrix(10)

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

@oscargus
Copy link
Contributor Author

Thanks! Forgot about those extended ones...

@oscargus
Copy link
Contributor Author

One may want to consider a SymbolicRangeError which inherits from ValueError (or maybe TypeError sometimes that is thrown as well).

assert Range(n)[0] == 0
assert Range(n, n+1)[0] == n
assert Range(n).size == n
assert Range(n, n+1).size == 1
Copy link
Member

Choose a reason for hiding this comment

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

nice progression of tests!

@smichr
Copy link
Member

smichr commented Aug 24, 2021

lgtm

@smichr smichr merged commit 6fdba11 into sympy:master Aug 24, 2021
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.

imageset over Range does not work
4 participants