Skip to content

Commit

Permalink
gh-38277: Deprecate is_ChowCycle, is_CohomologyClass, `is_Divisor…
Browse files Browse the repository at this point in the history
…`, `is_ToricDivisor`

    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes #12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes #12345". -->

- Part of #32414

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - #12345: short description why this is a dependency -->
<!-- - #34567: ... -->
    
URL: #38277
Reported by: Matthias Köppe
Reviewer(s): Travis Scrimshaw
  • Loading branch information
Release Manager committed Jul 20, 2024
2 parents 76a0869 + a01b099 commit 89c7d56
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 12 deletions.
8 changes: 8 additions & 0 deletions src/sage/schemes/generic/divisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,18 @@ def is_Divisor(x):
sage: x,y = AffineSpace(2, GF(5), names='xy').gens()
sage: C = Curve(y^2 - x^9 - x)
sage: is_Divisor(C.divisor([]))
doctest:warning...
DeprecationWarning: The function is_Divisor is deprecated;
use 'isinstance(..., Divisor_generic)' instead.
See https://github.com/sagemath/sage/issues/38277 for details.
True
sage: is_Divisor("Ceci n'est pas un diviseur")
False
"""
from sage.misc.superseded import deprecation
deprecation(38277,
"The function is_Divisor is deprecated; "
"use 'isinstance(..., Divisor_generic)' instead.")
return isinstance(x, Divisor_generic)


Expand Down
16 changes: 12 additions & 4 deletions src/sage/schemes/toric/chow_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@

import sage.geometry.abc
from sage.schemes.toric.variety import ToricVariety_field
from sage.schemes.toric.divisor import is_ToricDivisor
from sage.schemes.toric.divisor import ToricDivisor_generic


class ChowCycle(FGP_Element):
Expand Down Expand Up @@ -408,7 +408,7 @@ def intersection_with_divisor(self, divisor):
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)]
"""
assert is_ToricDivisor(divisor), f'{divisor} is not a toric divisor'
assert isinstance(divisor, ToricDivisor_generic), f'{divisor} is not a toric divisor'

A = self.parent() # the Chow group
X = A._variety # the toric variety
Expand Down Expand Up @@ -610,7 +610,7 @@ def __init__(self, toric_variety, base_ring, check):
Chow group of 2-d CPR-Fano toric variety covered by 3 affine patches
sage: isinstance(A, ChowGroup_class)
True
sage: is_ChowCycle(A.an_element())
sage: isinstance(A.an_element(), ChowCycle)
True
TESTS::
Expand Down Expand Up @@ -701,7 +701,7 @@ def _element_constructor_(self, x, check=True):
if isinstance(x, sage.geometry.abc.ConvexRationalPolyhedralCone):
cone = fan.embed(x)
return self.element_class(self, self._cone_to_V(cone), False)
if is_ToricDivisor(x):
if isinstance(x, ToricDivisor_generic):
v = sum(x.coefficient(i) * self._cone_to_V(onecone)
for i, onecone in enumerate(fan(1)))
return self.element_class(self, v, False)
Expand Down Expand Up @@ -1244,10 +1244,18 @@ def is_ChowCycle(x) -> bool:
sage: A = P2.Chow_group()
sage: from sage.schemes.toric.chow_group import *
sage: is_ChowCycle(A)
doctest:warning...
DeprecationWarning: The function is_ChowCycle is deprecated;
use 'isinstance(..., ChowCycle)' instead.
See https://github.com/sagemath/sage/issues/38277 for details.
False
sage: is_ChowCycle(A.an_element())
True
sage: is_ChowCycle('Victoria')
False
"""
from sage.misc.superseded import deprecation
deprecation(38277,
"The function is_ChowCycle is deprecated; "
"use 'isinstance(..., ChowCycle)' instead.")
return isinstance(x, ChowCycle)
12 changes: 10 additions & 2 deletions src/sage/schemes/toric/divisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,21 @@ def is_ToricDivisor(x):
sage: from sage.schemes.toric.divisor import is_ToricDivisor
sage: is_ToricDivisor(1)
doctest:warning...
DeprecationWarning: The function is_ToricDivisor is deprecated;
use 'isinstance(..., ToricDivisor_generic)' instead.
See https://github.com/sagemath/sage/issues/38277 for details.
False
sage: P2 = toric_varieties.P2()
sage: D = P2.divisor(0); D
V(x)
sage: is_ToricDivisor(D)
True
"""
from sage.misc.superseded import deprecation
deprecation(38277,
"The function is_ToricDivisor is deprecated; "
"use 'isinstance(..., ToricDivisor_generic)' instead.")
return isinstance(x, ToricDivisor_generic)


Expand Down Expand Up @@ -1819,7 +1827,7 @@ def _element_constructor_(self, x, check=True, reduce=True):
sage: TDiv(TDiv.gen(0), check=True)
V(x)
"""
if is_ToricDivisor(x):
if isinstance(x, ToricDivisor_generic):
if x.parent() is self:
return x
else:
Expand Down Expand Up @@ -2014,7 +2022,7 @@ def _element_constructor_(self, x):
sage: Cl(D)
Divisor class [0, 0, 1, 0]
"""
if is_ToricDivisor(x):
if isinstance(x, ToricDivisor_generic):
x = self._projection_matrix * vector(x)
if isinstance(x, Vector):
x = list(x)
Expand Down
12 changes: 6 additions & 6 deletions src/sage/schemes/toric/morphism.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,8 +755,8 @@ def pullback_divisor(self, divisor):
sage: f.pullback_divisor(D)
4*V(z0) + 2*V(z1)
"""
from sage.schemes.toric.divisor import is_ToricDivisor
if not (is_ToricDivisor(divisor) and divisor.is_QQ_Cartier()):
from sage.schemes.toric.divisor import ToricDivisor_generic
if not (isinstance(divisor, ToricDivisor_generic) and divisor.is_QQ_Cartier()):
raise ValueError('the divisor must be torus-invariant and QQ-Cartier')
m = divisor.m(self._defining_cone)
values = []
Expand Down Expand Up @@ -1300,8 +1300,8 @@ def pullback_divisor(self, divisor):
sage: square.pullback_divisor(D)
2*V(z)
"""
from sage.schemes.toric.divisor import is_ToricDivisor
if not (is_ToricDivisor(divisor) and divisor.is_QQ_Cartier()):
from sage.schemes.toric.divisor import ToricDivisor_generic
if not (isinstance(divisor, ToricDivisor_generic) and divisor.is_QQ_Cartier()):
raise ValueError('the divisor must be torus-invariant and QQ-Cartier')
fm = self.fan_morphism()
values = []
Expand Down Expand Up @@ -1978,8 +1978,8 @@ def pullback_divisor(self, divisor):
sage: fc.embedding_morphism().pullback_divisor(D)
-V(z0) - 3*V(z1) - 3*V(z2)
"""
from sage.schemes.toric.divisor import is_ToricDivisor
if not (is_ToricDivisor(divisor) and divisor.is_QQ_Cartier()):
from sage.schemes.toric.divisor import ToricDivisor_generic
if not (isinstance(divisor, ToricDivisor_generic) and divisor.is_QQ_Cartier()):
raise ValueError('the divisor must be torus-invariant and QQ-Cartier')
m = divisor.m(self.defining_cone())
values = []
Expand Down
8 changes: 8 additions & 0 deletions src/sage/schemes/toric/variety.py
Original file line number Diff line number Diff line change
Expand Up @@ -3313,12 +3313,20 @@ def is_CohomologyClass(x):
sage: HH = P2.cohomology_ring()
sage: from sage.schemes.toric.variety import is_CohomologyClass
sage: is_CohomologyClass( HH.one() ) # needs sage.libs.singular
doctest:warning...
DeprecationWarning: The function is_CohomologyClass is deprecated;
use 'isinstance(..., CohomologyClass)' instead.
See https://github.com/sagemath/sage/issues/38277 for details.
True
sage: is_CohomologyClass( HH(P2.fan(1)[0]) ) # needs sage.libs.singular
True
sage: is_CohomologyClass('z')
False
"""
from sage.misc.superseded import deprecation
deprecation(38277,
"The function is_CohomologyClass is deprecated; "
"use 'isinstance(..., CohomologyClass)' instead.")
return isinstance(x, CohomologyClass)


Expand Down

0 comments on commit 89c7d56

Please sign in to comment.