Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding generic change_ring() method and some other touchups. #36472

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 34 additions & 19 deletions src/sage/rings/ideal.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,20 @@
addition to using the :func:`Ideal` function:

- ``R.ideal(gens, coerce=True)``
- ``gens*R``
- ``R*gens``
- ``gens * R``
- ``R * gens``

INPUT:

- ``R`` - A ring (optional; if not given, will try to infer it from
``gens``)
- ``R`` -- (optional) a ring; if not given, will try to infer
it from ``gens``
- ``gens`` -- list of elements generating the ideal
- ``coerce`` -- (default: ``True``) boolean;
whether ``gens`` need to be coerced into the ring

- ``gens`` - list of elements generating the ideal
OUTPUT:

- ``coerce`` - bool (optional, default: ``True``);
whether ``gens`` need to be coerced into the ring.


OUTPUT: The ideal of ring generated by ``gens``.
the ideal of ring generated by ``gens``

EXAMPLES::

Expand Down Expand Up @@ -254,12 +253,10 @@

INPUT:

- ``ring`` -- A ring

- ``gens`` -- The generators for this ideal

- ``coerce`` -- (default: ``True``) If ``gens`` needs to be coerced
into ``ring``.
- ``ring`` -- a ring
- ``gens`` -- the generators for this ideal
- ``coerce`` -- (default: ``True``) if ``gens`` needs to be
coerced into ``ring``

EXAMPLES::

Expand Down Expand Up @@ -319,7 +316,7 @@
return '\n(\n %s\n)\n' % (',\n\n '.join(L))
return '(%s)' % (', '.join(L))

def __repr__(self):
def _repr_(self):
"""
Return a string representation of ``self``.

Expand Down Expand Up @@ -689,6 +686,24 @@
"""
return self.gens()

def change_ring(self, R, *args, **kwds):
r"""
Convert ``self`` into an ideal of the ring ``R``.

EXAMPLES::

sage: Sym = SymmetricFunctions(QQ)
sage: s = Sym.s()
sage: h = Sym.h()
sage: I = s.ideal([s[2], s[1,1]]); I
Ideal (s[2], s[1, 1]) of Symmetric Functions over Rational Field in the Schur basis
sage: I.change_ring(h)
Ideal (h[2], h[1, 1] - h[2]) of Symmetric Functions over Rational Field in the homogeneous basis
"""
if R is self:
return self

Check warning on line 704 in src/sage/rings/ideal.py

View check run for this annotation

Codecov / codecov/patch

src/sage/rings/ideal.py#L704

Added line #L704 was not covered by tests
return R.ideal([R(g) for g in self.__gens], *args, **kwds)

def is_maximal(self):
r"""
Return ``True`` if the ideal is maximal in the ring containing the
Expand Down Expand Up @@ -1269,7 +1284,7 @@
#def __init__(self, ring, gen):
# Ideal_generic.__init__(self, ring, [gen])

def __repr__(self):
def _repr_(self):
"""
Return a string representation of ``self``.

Expand Down Expand Up @@ -1705,7 +1720,7 @@

See :func:`Ideal()`.
"""
def __repr__(self):
def _repr_(self):
"""
Return a string representation of ``self``.

Expand Down