This repository was archived by the owner on Jan 30, 2023. It is now read-only.
Commit 9552c8a
Trac #25296: RingConverter should handle named variables by default
In the current version of Sage, when a !RingConverter is used to convert
from the symbolic ring to an algebraic ring, all converted variables
must be specified in the !RingConverter's dictionary. For example,
{{{
sage: from sage.symbolic.expression_conversions import RingConverter
sage: R = QQ['x']
sage: RC = RingConverter(R, {x: R.0})
sage: RC(x)
x
}}}
Attempting to convert without a dictionary produces an error:
{{{
sage: RC = RingConverter(R)
sage: RC(x)
...
TypeError:
}}}
This patch changes this behavior so that if a variable is not found in
the !RingConverter's dictionary, an attempt is make to convert it to the
ring using the ring's element constructor. This allows the last example
to work as expected; the symbolic variable "x" is converted to the ring
element of the same name.
{{{
sage: from sage.symbolic.expression_conversions import RingConverter
sage: R = QQ['x']
sage: RC = RingConverter(R)
sage: R(x)
x
sage: x.parent()
Symbolic Ring
sage: R(x).parent()
Univariate Polynomial Ring in x over Rational Field
}}}
URL: https://trac.sagemath.org/25296
Reported by: gh-BrentBaccala
Ticket author(s): Brent Baccala
Reviewer(s): Marc Mezzarobba1 file changed
+11
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1801 | 1801 | | |
1802 | 1802 | | |
1803 | 1803 | | |
1804 | | - | |
1805 | | - | |
| 1804 | + | |
| 1805 | + | |
| 1806 | + | |
1806 | 1807 | | |
1807 | 1808 | | |
1808 | 1809 | | |
| |||
1815 | 1816 | | |
1816 | 1817 | | |
1817 | 1818 | | |
1818 | | - | |
| 1819 | + | |
| 1820 | + | |
| 1821 | + | |
| 1822 | + | |
| 1823 | + | |
| 1824 | + | |
| 1825 | + | |
1819 | 1826 | | |
1820 | 1827 | | |
1821 | 1828 | | |
1822 | 1829 | | |
1823 | | - | |
| 1830 | + | |
1824 | 1831 | | |
1825 | 1832 | | |
1826 | 1833 | | |
| |||
0 commit comments