Skip to content

Commit 7cdd497

Browse files
committed
remove more duplicate code
1 parent 3edbf8b commit 7cdd497

File tree

2 files changed

+6
-69
lines changed

2 files changed

+6
-69
lines changed

src/sage/categories/rings.py

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -764,73 +764,6 @@ def unit_ideal(self):
764764
"""
765765
return self._ideal_class_(1)(self, [self.one()])
766766

767-
def _ideal_class_(self, n=0):
768-
r"""
769-
Return a callable object that can be used to create ideals in this
770-
ring.
771-
772-
EXAMPLES::
773-
774-
sage: MS = MatrixSpace(QQ, 2, 2) # needs sage.modules
775-
sage: MS._ideal_class_() # needs sage.modules
776-
<class 'sage.rings.noncommutative_ideals.Ideal_nc'>
777-
778-
Since :issue:`7797`, non-commutative rings have ideals as well::
779-
780-
sage: A = SteenrodAlgebra(2) # needs sage.combinat sage.modules
781-
sage: A._ideal_class_() # needs sage.combinat sage.modules
782-
<class 'sage.rings.noncommutative_ideals.Ideal_nc'>
783-
"""
784-
from sage.rings.noncommutative_ideals import Ideal_nc
785-
return Ideal_nc
786-
787-
@cached_method
788-
def zero_ideal(self):
789-
"""
790-
Return the zero ideal of this ring (cached).
791-
792-
EXAMPLES::
793-
794-
sage: ZZ.zero_ideal()
795-
Principal ideal (0) of Integer Ring
796-
sage: QQ.zero_ideal()
797-
Principal ideal (0) of Rational Field
798-
sage: QQ['x'].zero_ideal()
799-
Principal ideal (0) of Univariate Polynomial Ring in x over Rational Field
800-
801-
The result is cached::
802-
803-
sage: ZZ.zero_ideal() is ZZ.zero_ideal()
804-
True
805-
806-
TESTS:
807-
808-
Make sure that :issue:`13644` is fixed::
809-
810-
sage: # needs sage.rings.padics
811-
sage: K = Qp(3)
812-
sage: R.<a> = K[]
813-
sage: L.<a> = K.extension(a^2-3)
814-
sage: L.ideal(a)
815-
Principal ideal (1 + O(a^40)) of 3-adic Eisenstein Extension Field in a defined by a^2 - 3
816-
"""
817-
return self._ideal_class_(1)(self, [self.zero()])
818-
819-
def principal_ideal(self, gen, coerce=True):
820-
"""
821-
Return the principal ideal generated by gen.
822-
823-
EXAMPLES::
824-
825-
sage: R.<x,y> = ZZ[]
826-
sage: R.principal_ideal(x+2*y)
827-
Ideal (x + 2*y) of Multivariate Polynomial Ring in x, y over Integer Ring
828-
"""
829-
C = self._ideal_class_(1)
830-
if coerce:
831-
gen = self(gen)
832-
return C(self, [gen])
833-
834767
def characteristic(self):
835768
"""
836769
Return the characteristic of this ring.

src/sage/categories/rngs.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ def _ideal_class_(self, n=0):
9797
The argument `n`, standing for the number of generators
9898
of the ideal, is ignored.
9999
100-
EXAMPLES:
100+
EXAMPLES::
101+
102+
sage: MS = MatrixSpace(QQ, 2, 2) # needs sage.modules
103+
sage: MS._ideal_class_() # needs sage.modules
104+
<class 'sage.rings.noncommutative_ideals.Ideal_nc'>
101105
102106
Since :issue:`7797`, non-commutative rings have ideals as well::
103107
@@ -153,4 +157,4 @@ def zero_ideal(self):
153157
sage: L.ideal(a)
154158
Principal ideal (1 + O(a^40)) of 3-adic Eisenstein Extension Field in a defined by a^2 - 3
155159
"""
156-
return self.principal_ideal(self.zero(), coerce=False)
160+
return self._ideal_class_(1)(self, [self.zero()])

0 commit comments

Comments
 (0)