Skip to content

Commit 33950d6

Browse files
author
Release Manager
committed
gh-41094: Add some missing docstrings to `multi_polynomial_ring_base.pyx` This PR adds a few missing docstrings and doctests to `multi_polynomial_ring_base.pyx`. While I am at it, I also fixed a typo in `scheme.py`. - [X] The title is concise and informative. - [X] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [X] I have created tests covering the changes. - [X] I have updated the documentation and checked the documentation preview. URL: #41094 Reported by: Rubén Muñoz--Bertrand Reviewer(s): David Coudert, Rubén Muñoz--Bertrand
2 parents 79f3de4 + 23e4c19 commit 33950d6

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

src/sage/rings/polynomial/multi_polynomial_ring_base.pyx

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,21 @@ cdef class MPolynomialRing_base(CommutativeRing):
868868
return False
869869

870870
def term_order(self):
871+
"""
872+
Return the term order of ``self``.
873+
874+
OUTPUT: a :class:`~sage.rings.polynomial.term_order.TermOrder` of the
875+
variables of ``self``.
876+
877+
EXAMPLES::
878+
879+
sage: R.<x,y,z> = PolynomialRing(ZZ, 3)
880+
sage: R.term_order()
881+
Degree reverse lexicographic term order
882+
sage: S.<t,u> = PolynomialRing(QQ, 2, order='lex')
883+
sage: S.term_order()
884+
Lexicographic term order
885+
"""
871886
return self._term_order
872887

873888
def characteristic(self):
@@ -886,6 +901,29 @@ cdef class MPolynomialRing_base(CommutativeRing):
886901
return self.base_ring().characteristic()
887902

888903
def gen(self, n=0):
904+
"""
905+
Return the ``n``-th indeterminate generator of ``self``.
906+
907+
INPUT:
908+
909+
- ``n`` -- integer (default: ``0``); number of the generator
910+
911+
EXAMPLES::
912+
913+
sage: R = CC['x,y,z']
914+
sage: x = R.gen()
915+
sage: x
916+
x
917+
sage: parent(x)
918+
Multivariate Polynomial Ring in x, y, z over Complex Field with 53
919+
bits of precision
920+
sage: R.gen(2)
921+
z
922+
sage: R.gen(23)
923+
Traceback (most recent call last):
924+
...
925+
ValueError: generator not defined
926+
"""
889927
if n < 0 or n >= self._ngens:
890928
raise ValueError("generator not defined")
891929
return self._gens[int(n)]
@@ -943,9 +981,30 @@ cdef class MPolynomialRing_base(CommutativeRing):
943981
return self.base_ring()
944982

945983
def krull_dimension(self):
984+
"""
985+
Return the Krull dimension of ``self``.
986+
987+
EXAMPLES::
988+
989+
sage: R = ZZ['t,u']
990+
sage: R.krull_dimension()
991+
3
992+
sage: S = QQ['x,y']
993+
sage: S.krull_dimension()
994+
2
995+
"""
946996
return self.base_ring().krull_dimension() + self.ngens()
947997

948998
def ngens(self):
999+
"""
1000+
Return the number of indeterminate generators of ``self``.
1001+
1002+
EXAMPLES::
1003+
1004+
sage: R = RR['x,y']
1005+
sage: R.ngens()
1006+
2
1007+
"""
9491008
return self._ngens
9501009

9511010
def _monomial_order_function(self):

src/sage/schemes/generic/scheme.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def __init__(self, X=None, category=None):
120120
# X is a morphism of Rings
121121
self._base_ring = X.codomain()
122122
else:
123-
raise ValueError('The base must be define by a scheme, '
123+
raise ValueError('The base must be defined by a scheme, '
124124
'scheme morphism, or commutative ring.')
125125

126126
from sage.categories.schemes import Schemes

0 commit comments

Comments
 (0)