Skip to content

Commit

Permalink
gh-36841: Change default domain of SR.var()
Browse files Browse the repository at this point in the history
    
This patch fixes #36833 by changing the default domain of SR.var()
function to complex. By this way, every variable whose domain is not
defined will be considered
in complex plane, by default.

The issue was with the default value only because whenever we were
defining a variable without specifying any domain it was calling
symbol() function with domain=None; Subsequently, it calls
new_Expression_symbol() function with domain=None. In this code, I found
that it was not giving any specific domain to the variable and so when
we define a new variable using SR.var() function, it is passing the
is_real() (Because it does not have any specific domain) test but giving
the wrong answer on factor() function, if we assume that the variable is
in complex plane by default which is correct according to the
documentation.

<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes #1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->

<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes #12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.



<!-- List all open PRs that this PR logically depends on
- #12345: short description why this is a dependency
- #34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: #36841
Reported by: Ruchit Jagodara
Reviewer(s): Dima Pasechnik, Ruchit Jagodara
  • Loading branch information
Release Manager committed Jan 12, 2024
2 parents 152035b + 053d50c commit 9b73d6c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/sage/symbolic/ring.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ cdef class SymbolicRing(sage.rings.abc.SymbolicRing):
- ``n`` -- (optional) positive integer; number of symbolic variables, indexed from `0` to `n-1`
- ``domain`` -- (optional) specify the domain of the variable(s); it is the complex plane
- ``domain`` -- (optional) specify the domain of the variable(s); it is None
by default, and possible options are (non-exhaustive list, see note below):
``'real'``, ``'complex'``, ``'positive'``, ``'integer'`` and ``'noninteger'``
Expand All @@ -780,7 +780,7 @@ cdef class SymbolicRing(sage.rings.abc.SymbolicRing):
EXAMPLES:
Create a variable `zz` (complex by default)::
Create a variable `zz`::
sage: zz = SR.var('zz'); zz
zz
Expand Down

0 comments on commit 9b73d6c

Please sign in to comment.