Skip to content

Commit

Permalink
Fixes for reviewer comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kwankyu committed Mar 8, 2024
1 parent 38c69a7 commit 3b31b1a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 27 deletions.
7 changes: 2 additions & 5 deletions src/sage/rings/function_field/function_field_polymod.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@
from .function_field import FunctionField
from .function_field_rational import RationalFunctionField

_FunctionFields = FunctionFields()
_NumberFields = NumberFields()


class FunctionField_polymod(FunctionField):
"""
Expand Down Expand Up @@ -164,7 +161,7 @@ def __init__(self, polynomial, names, category=None):
self._polynomial = polynomial

FunctionField.__init__(self, base_field, names=names,
category=_FunctionFields.or_subcategory(category))
category=FunctionFields().or_subcategory(category))

from .place_polymod import FunctionFieldPlace_polymod
self._place_class = FunctionFieldPlace_polymod
Expand Down Expand Up @@ -1861,7 +1858,7 @@ def genus(self):
The genus is computed by the Hurwitz genus formula.
"""
k, _ = self.exact_constant_field()
if k in _NumberFields:
if k in NumberFields():
k_degree = k.relative_degree()
else:
k_degree = k.degree()
Expand Down
1 change: 1 addition & 0 deletions src/sage/schemes/curves/affine_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -2068,6 +2068,7 @@ def _genus(self):
TESTS::
sage: # needs sage.rings.number_field
sage: R.<T> = QQ[]
sage: N.<a> = NumberField(T^2 + 1)
sage: A2.<x,y> = AffineSpace(N, 2)
Expand Down
23 changes: 10 additions & 13 deletions src/sage/schemes/curves/constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@
IntegralAffinePlaneCurve,
IntegralAffinePlaneCurve_finite_field)

_Fields = Fields()
_NumberFields = NumberFields()


def _is_irreducible_and_reduced(F) -> bool:
"""
Expand Down Expand Up @@ -312,16 +309,16 @@ def Curve(F, A=None):
if A.coordinate_ring().ideal(F).is_zero():
if isinstance(k, FiniteField):
return IntegralAffineCurve_finite_field(A, F)
if k in _Fields:
if k in Fields():
return IntegralAffineCurve(A, F)
return AffineCurve(A, F)
raise TypeError(f"{F} does not define a curve in one-dimensional affine space")

Check warning on line 315 in src/sage/schemes/curves/constructor.py

View check run for this annotation

Codecov / codecov/patch

src/sage/schemes/curves/constructor.py#L314-L315

Added lines #L314 - L315 were not covered by tests
if n != 2:
if isinstance(k, FiniteField):
if A.coordinate_ring().ideal(F).is_prime():
return IntegralAffineCurve_finite_field(A, F)
if k in _Fields:
if (k == QQ or k in _NumberFields) and A.coordinate_ring().ideal(F).is_prime():
if k in Fields():
if (k == QQ or k in NumberFields()) and A.coordinate_ring().ideal(F).is_prime():
return IntegralAffineCurve(A, F)
return AffineCurve_field(A, F)
return AffineCurve(A, F)
Expand All @@ -334,8 +331,8 @@ def Curve(F, A=None):
if _is_irreducible_and_reduced(F):
return IntegralAffinePlaneCurve_finite_field(A, F)
return AffinePlaneCurve_finite_field(A, F)
if k in _Fields:
if (k == QQ or k in _NumberFields) and _is_irreducible_and_reduced(F):
if k in Fields():
if (k == QQ or k in NumberFields()) and _is_irreducible_and_reduced(F):
return IntegralAffinePlaneCurve(A, F)
return AffinePlaneCurve_field(A, F)
return AffinePlaneCurve(A, F)
Expand All @@ -345,7 +342,7 @@ def Curve(F, A=None):
if A.coordinate_ring().ideal(F).is_zero():
if isinstance(k, FiniteField):
return IntegralProjectiveCurve_finite_field(A, F)
if k in _Fields:
if k in Fields():
return IntegralProjectiveCurve(A, F)
return ProjectiveCurve(A, F)
raise TypeError(f"{F} does not define a curve in one-dimensional projective space")

Check warning on line 348 in src/sage/schemes/curves/constructor.py

View check run for this annotation

Codecov / codecov/patch

src/sage/schemes/curves/constructor.py#L347-L348

Added lines #L347 - L348 were not covered by tests
Expand All @@ -355,8 +352,8 @@ def Curve(F, A=None):
if isinstance(k, FiniteField):
if A.coordinate_ring().ideal(F).is_prime():
return IntegralProjectiveCurve_finite_field(A, F)
if k in _Fields:
if (k == QQ or k in _NumberFields) and A.coordinate_ring().ideal(F).is_prime():
if k in Fields():
if (k == QQ or k in NumberFields()) and A.coordinate_ring().ideal(F).is_prime():
return IntegralProjectiveCurve(A, F)
return ProjectiveCurve_field(A, F)
return ProjectiveCurve(A, F)
Expand All @@ -374,8 +371,8 @@ def Curve(F, A=None):
if _is_irreducible_and_reduced(F):
return IntegralProjectivePlaneCurve_finite_field(A, F)
return ProjectivePlaneCurve_finite_field(A, F)
if k in _Fields:
if (k == QQ or k in _NumberFields) and _is_irreducible_and_reduced(F):
if k in Fields():
if (k == QQ or k in NumberFields()) and _is_irreducible_and_reduced(F):
return IntegralProjectivePlaneCurve(A, F)
return ProjectivePlaneCurve_field(A, F)
return ProjectivePlaneCurve(A, F)
Expand Down
18 changes: 9 additions & 9 deletions src/sage/schemes/curves/curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,17 +238,17 @@ def geometric_genus(self):
sage: C.geometric_genus()
3
Note that the geometric genus is only defined for `geometrically
irreducible curve <https://stacks.math.columbia.edu/tag/0BYE>`_. This
method does not check the condition. Be warned that you may get a
nonsensical result if the curve is not geometrically irreducible.
.. WARNING::
A curve that is not geometrically irreducible::
Geometric genus is only defined for `geometrically irreducible curve
<https://stacks.math.columbia.edu/tag/0BYE>`_. This method does not
check the condition. You may get a nonsensical result if the curve is
not geometrically irreducible::
sage: P2.<x,y,z> = ProjectiveSpace(QQ, 2)
sage: C = Curve(x^2 + y^2, P2)
sage: C.geometric_genus() # nonsense!
-1
sage: P2.<x,y,z> = ProjectiveSpace(QQ, 2)
sage: C = Curve(x^2 + y^2, P2)
sage: C.geometric_genus() # nonsense!
-1
"""
try:
return self._genus
Expand Down

0 comments on commit 3b31b1a

Please sign in to comment.