Skip to content

Commit 89c7d56

Browse files
author
Release Manager
committed
sagemathgh-38277: Deprecate `is_ChowCycle`, `is_CohomologyClass`, `is_Divisor`, `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 sagemath#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 sagemath#12345". --> - Part of sagemath#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, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#38277 Reported by: Matthias Köppe Reviewer(s): Travis Scrimshaw
2 parents 76a0869 + a01b099 commit 89c7d56

File tree

5 files changed

+44
-12
lines changed

5 files changed

+44
-12
lines changed

src/sage/schemes/generic/divisor.py

+8
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,18 @@ def is_Divisor(x):
111111
sage: x,y = AffineSpace(2, GF(5), names='xy').gens()
112112
sage: C = Curve(y^2 - x^9 - x)
113113
sage: is_Divisor(C.divisor([]))
114+
doctest:warning...
115+
DeprecationWarning: The function is_Divisor is deprecated;
116+
use 'isinstance(..., Divisor_generic)' instead.
117+
See https://github.com/sagemath/sage/issues/38277 for details.
114118
True
115119
sage: is_Divisor("Ceci n'est pas un diviseur")
116120
False
117121
"""
122+
from sage.misc.superseded import deprecation
123+
deprecation(38277,
124+
"The function is_Divisor is deprecated; "
125+
"use 'isinstance(..., Divisor_generic)' instead.")
118126
return isinstance(x, Divisor_generic)
119127

120128

src/sage/schemes/toric/chow_group.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132

133133
import sage.geometry.abc
134134
from sage.schemes.toric.variety import ToricVariety_field
135-
from sage.schemes.toric.divisor import is_ToricDivisor
135+
from sage.schemes.toric.divisor import ToricDivisor_generic
136136

137137

138138
class ChowCycle(FGP_Element):
@@ -408,7 +408,7 @@ def intersection_with_divisor(self, divisor):
408408
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
409409
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)]
410410
"""
411-
assert is_ToricDivisor(divisor), f'{divisor} is not a toric divisor'
411+
assert isinstance(divisor, ToricDivisor_generic), f'{divisor} is not a toric divisor'
412412

413413
A = self.parent() # the Chow group
414414
X = A._variety # the toric variety
@@ -610,7 +610,7 @@ def __init__(self, toric_variety, base_ring, check):
610610
Chow group of 2-d CPR-Fano toric variety covered by 3 affine patches
611611
sage: isinstance(A, ChowGroup_class)
612612
True
613-
sage: is_ChowCycle(A.an_element())
613+
sage: isinstance(A.an_element(), ChowCycle)
614614
True
615615
616616
TESTS::
@@ -701,7 +701,7 @@ def _element_constructor_(self, x, check=True):
701701
if isinstance(x, sage.geometry.abc.ConvexRationalPolyhedralCone):
702702
cone = fan.embed(x)
703703
return self.element_class(self, self._cone_to_V(cone), False)
704-
if is_ToricDivisor(x):
704+
if isinstance(x, ToricDivisor_generic):
705705
v = sum(x.coefficient(i) * self._cone_to_V(onecone)
706706
for i, onecone in enumerate(fan(1)))
707707
return self.element_class(self, v, False)
@@ -1244,10 +1244,18 @@ def is_ChowCycle(x) -> bool:
12441244
sage: A = P2.Chow_group()
12451245
sage: from sage.schemes.toric.chow_group import *
12461246
sage: is_ChowCycle(A)
1247+
doctest:warning...
1248+
DeprecationWarning: The function is_ChowCycle is deprecated;
1249+
use 'isinstance(..., ChowCycle)' instead.
1250+
See https://github.com/sagemath/sage/issues/38277 for details.
12471251
False
12481252
sage: is_ChowCycle(A.an_element())
12491253
True
12501254
sage: is_ChowCycle('Victoria')
12511255
False
12521256
"""
1257+
from sage.misc.superseded import deprecation
1258+
deprecation(38277,
1259+
"The function is_ChowCycle is deprecated; "
1260+
"use 'isinstance(..., ChowCycle)' instead.")
12531261
return isinstance(x, ChowCycle)

src/sage/schemes/toric/divisor.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,21 @@ def is_ToricDivisor(x):
209209
210210
sage: from sage.schemes.toric.divisor import is_ToricDivisor
211211
sage: is_ToricDivisor(1)
212+
doctest:warning...
213+
DeprecationWarning: The function is_ToricDivisor is deprecated;
214+
use 'isinstance(..., ToricDivisor_generic)' instead.
215+
See https://github.com/sagemath/sage/issues/38277 for details.
212216
False
213217
sage: P2 = toric_varieties.P2()
214218
sage: D = P2.divisor(0); D
215219
V(x)
216220
sage: is_ToricDivisor(D)
217221
True
218222
"""
223+
from sage.misc.superseded import deprecation
224+
deprecation(38277,
225+
"The function is_ToricDivisor is deprecated; "
226+
"use 'isinstance(..., ToricDivisor_generic)' instead.")
219227
return isinstance(x, ToricDivisor_generic)
220228

221229

@@ -1819,7 +1827,7 @@ def _element_constructor_(self, x, check=True, reduce=True):
18191827
sage: TDiv(TDiv.gen(0), check=True)
18201828
V(x)
18211829
"""
1822-
if is_ToricDivisor(x):
1830+
if isinstance(x, ToricDivisor_generic):
18231831
if x.parent() is self:
18241832
return x
18251833
else:
@@ -2014,7 +2022,7 @@ def _element_constructor_(self, x):
20142022
sage: Cl(D)
20152023
Divisor class [0, 0, 1, 0]
20162024
"""
2017-
if is_ToricDivisor(x):
2025+
if isinstance(x, ToricDivisor_generic):
20182026
x = self._projection_matrix * vector(x)
20192027
if isinstance(x, Vector):
20202028
x = list(x)

src/sage/schemes/toric/morphism.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -755,8 +755,8 @@ def pullback_divisor(self, divisor):
755755
sage: f.pullback_divisor(D)
756756
4*V(z0) + 2*V(z1)
757757
"""
758-
from sage.schemes.toric.divisor import is_ToricDivisor
759-
if not (is_ToricDivisor(divisor) and divisor.is_QQ_Cartier()):
758+
from sage.schemes.toric.divisor import ToricDivisor_generic
759+
if not (isinstance(divisor, ToricDivisor_generic) and divisor.is_QQ_Cartier()):
760760
raise ValueError('the divisor must be torus-invariant and QQ-Cartier')
761761
m = divisor.m(self._defining_cone)
762762
values = []
@@ -1300,8 +1300,8 @@ def pullback_divisor(self, divisor):
13001300
sage: square.pullback_divisor(D)
13011301
2*V(z)
13021302
"""
1303-
from sage.schemes.toric.divisor import is_ToricDivisor
1304-
if not (is_ToricDivisor(divisor) and divisor.is_QQ_Cartier()):
1303+
from sage.schemes.toric.divisor import ToricDivisor_generic
1304+
if not (isinstance(divisor, ToricDivisor_generic) and divisor.is_QQ_Cartier()):
13051305
raise ValueError('the divisor must be torus-invariant and QQ-Cartier')
13061306
fm = self.fan_morphism()
13071307
values = []
@@ -1978,8 +1978,8 @@ def pullback_divisor(self, divisor):
19781978
sage: fc.embedding_morphism().pullback_divisor(D)
19791979
-V(z0) - 3*V(z1) - 3*V(z2)
19801980
"""
1981-
from sage.schemes.toric.divisor import is_ToricDivisor
1982-
if not (is_ToricDivisor(divisor) and divisor.is_QQ_Cartier()):
1981+
from sage.schemes.toric.divisor import ToricDivisor_generic
1982+
if not (isinstance(divisor, ToricDivisor_generic) and divisor.is_QQ_Cartier()):
19831983
raise ValueError('the divisor must be torus-invariant and QQ-Cartier')
19841984
m = divisor.m(self.defining_cone())
19851985
values = []

src/sage/schemes/toric/variety.py

+8
Original file line numberDiff line numberDiff line change
@@ -3313,12 +3313,20 @@ def is_CohomologyClass(x):
33133313
sage: HH = P2.cohomology_ring()
33143314
sage: from sage.schemes.toric.variety import is_CohomologyClass
33153315
sage: is_CohomologyClass( HH.one() ) # needs sage.libs.singular
3316+
doctest:warning...
3317+
DeprecationWarning: The function is_CohomologyClass is deprecated;
3318+
use 'isinstance(..., CohomologyClass)' instead.
3319+
See https://github.com/sagemath/sage/issues/38277 for details.
33163320
True
33173321
sage: is_CohomologyClass( HH(P2.fan(1)[0]) ) # needs sage.libs.singular
33183322
True
33193323
sage: is_CohomologyClass('z')
33203324
False
33213325
"""
3326+
from sage.misc.superseded import deprecation
3327+
deprecation(38277,
3328+
"The function is_CohomologyClass is deprecated; "
3329+
"use 'isinstance(..., CohomologyClass)' instead.")
33223330
return isinstance(x, CohomologyClass)
33233331

33243332

0 commit comments

Comments
 (0)