sagemath/sage

Replace "... is SR" by isinstance(..., sage.rings.abc.SymbolicRing) to handle symbolic subrings

Closed this issue · 26 comments

There are a number of tests ... is SR in the Sage library, as found by git grep 'is SR' src/sage/

These tests ignore symbolic subrings, as constructed by SR.subring(...).

All or most of these uses should be changed to isinstance(..., sage.rings.abc.SymbolicRing) or isinstance(..., sage.symbolic.ring.SymbolicRing) (if the module already imports other things from sage.symbolic)

In addition to handling the case of subrings, this will help with modularization (#32601).

We leave a few uses of is SR to follow-up tickets #31988, #31999.

CC: @dkrenn @egourgoulhon @orlitzky

Component: symbolics

Author: Matthias Koeppe

Branch/Commit: ff83c4c

Reviewer: Michael Orlitzky

Issue created by migration from https://trac.sagemath.org/ticket/32724

Commit: 45aab88

comment:2

here's one such change, cherry-picked from #32601


New commits:

45aab88src/sage/rings/polynomial/polynomial_element.pyx: Use isinstance(..., sage.rings.abc.SymbolicRing) instead of ... is SR

Author: Matthias Koeppe, ...

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

da82ac5src/sage/rings/polynomial/polynomial_element.pyx: Use isinstance(..., sage.rings.abc.SymbolicRing) instead of ... is SR
3c821bdsage.functions.other._eval_floor_ceil: Handle elements of symbolic subrings like elements of SR

Changed commit from 45aab88 to 3c821bd

Changed commit from 3c821bd to f1c9258

Branch pushed to git repo; I updated commit sha1. New commits:

f1c9258src/sage/combinat/q_analogues.py: Handle symbolic subrings like SR

Branch pushed to git repo; I updated commit sha1. New commits:

f98855bsrc/sage/dynamics/arithmetic_dynamics/projective_ds.py: Use sage.rings.abc.SymbolicRing instead of 'is SR'
7f1500esrc/sage/geometry/polyhedron/parent.py: For backend='normaliz', accept subrings of SR

Changed commit from f1c9258 to 7f1500e

Branch pushed to git repo; I updated commit sha1. New commits:

76e0962[Diff]ScalarFieldAlgebra._coerce_map_from_: Also coerce from subrings of SR

Changed commit from 7f1500e to 76e0962

Description changed:

--- 
+++ 
@@ -2,7 +2,7 @@
 
 These tests ignore symbolic subrings, as constructed by `SR.subring(...)`.
 
-All or most of these uses should be changed to `isinstance(..., sage.rings.abc.SymbolicRing)`.
+All or most of these uses should be changed to `isinstance(..., sage.rings.abc.SymbolicRing)` or `isinstance(..., sage.symbolic.ring.SymbolicRing)` (if the module already imports other things from `sage.symbolic`)
 
 In addition to handling the case of subrings, this will help with modularization (#32601).
 

Changed commit from 76e0962 to 5fca7fc

Branch pushed to git repo; I updated commit sha1. New commits:

b7470d1Matrix.is_{positive_operator,cross_positive,lyapunov_like}_on: Handle symbolic subrings like SR
5fca7fccontinued_fraction: Handle symbolic subrings like SR

Changed commit from 5fca7fc to 038eb9f

Branch pushed to git repo; I updated commit sha1. New commits:

038eb9fsrc/sage/symbolic/pynac_impl.pxi (py_is_integer, py_is_exact): Handle symbolic subrings like SR

Changed commit from 038eb9f to ff83c4c

Branch pushed to git repo; I updated commit sha1. New commits:

ff83c4csage.repl.ipython_kernel (widget_from_tuple, slider): Handle symbolic subrings like SR

Changed dependencies from #32665 to none

Changed author from Matthias Koeppe, ... to Matthias Koeppe

Description changed:

--- 
+++ 
@@ -6,3 +6,4 @@
 
 In addition to handling the case of subrings, this will help with modularization (#32601).
 
+We leave a few uses of `is SR` to follow-up tickets #31988, #31999.
comment:13

Now that we have a passing patchbot, this LGTM. I think "the symbolic ring (or a symbolic subring)" is awkward to repeat so many times and would be better phrased "a symbolic ring," but it's not important.

Reviewer: Michael Orlitzky

comment:14

Thank you!

I used this phrasing because I didn't want to think about the status of callable symbolic rings in this ticket.