Skip to content

Commit f933e1b

Browse files
author
Release Manager
committed
gh-40865: some typing -> bool for is_* methods just adding some simple `-> bool` annotations ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. URL: #40865 Reported by: Frédéric Chapoton Reviewer(s): David Coudert
2 parents 3f910e4 + c77e600 commit f933e1b

File tree

21 files changed

+141
-130
lines changed

21 files changed

+141
-130
lines changed

src/sage/algebras/hecke_algebras/cubic_hecke_matrix_rep.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class RepresentationType(Enum):
7474
sage: chmr.RepresentationType.RegularLeft.is_regular()
7575
True
7676
"""
77-
def is_split(self):
77+
def is_split(self) -> bool:
7878
r"""
7979
Return ``True`` if this representation type is absolutely split,
8080
``False`` else-wise.
@@ -88,7 +88,7 @@ def is_split(self):
8888
"""
8989
return self.value['split']
9090

91-
def is_regular(self):
91+
def is_regular(self) -> bool:
9292
r"""
9393
Return ``True`` if this representation type is regular, ``False``
9494
else-wise.

src/sage/categories/crystals.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def example(self, choice='highwt', **kwds):
152152

153153
class MorphismMethods:
154154
@cached_method
155-
def is_isomorphism(self):
155+
def is_isomorphism(self) -> bool:
156156
"""
157157
Check if ``self`` is a crystal isomorphism.
158158
@@ -178,7 +178,7 @@ def is_isomorphism(self):
178178

179179
# TODO: This could be moved to sets
180180
@cached_method
181-
def is_embedding(self):
181+
def is_embedding(self) -> bool:
182182
"""
183183
Check if ``self`` is an injective crystal morphism.
184184
@@ -213,7 +213,7 @@ def is_embedding(self):
213213
return True
214214

215215
@cached_method
216-
def is_strict(self):
216+
def is_strict(self) -> bool:
217217
"""
218218
Check if ``self`` is a strict crystal morphism.
219219
@@ -1301,7 +1301,7 @@ def number_of_connected_components(self):
13011301
"""
13021302
return len(self.connected_components_generators())
13031303

1304-
def is_connected(self):
1304+
def is_connected(self) -> bool:
13051305
"""
13061306
Return ``True`` if ``self`` is a connected crystal.
13071307
@@ -1528,7 +1528,7 @@ def s(self, i):
15281528
b = b.e(i)
15291529
return b
15301530

1531-
def is_highest_weight(self, index_set=None):
1531+
def is_highest_weight(self, index_set=None) -> bool:
15321532
r"""
15331533
Return ``True`` if ``self`` is a highest weight.
15341534
@@ -1550,9 +1550,10 @@ def is_highest_weight(self, index_set=None):
15501550
index_set = self.index_set()
15511551
return all(self.e(i) is None for i in index_set)
15521552

1553-
def is_lowest_weight(self, index_set=None):
1553+
def is_lowest_weight(self, index_set=None) -> bool:
15541554
r"""
15551555
Return ``True`` if ``self`` is a lowest weight.
1556+
15561557
Specifying the option ``index_set`` to be a subset `I` of the
15571558
index set of the underlying crystal, finds all lowest
15581559
weight vectors for arrows in `I`.

src/sage/categories/monoids.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def _div_(left, right):
274274
"""
275275
return left * ~right
276276

277-
def is_one(self):
277+
def is_one(self) -> bool:
278278
r"""
279279
Return whether ``self`` is the one of the monoid.
280280
@@ -603,7 +603,7 @@ def algebra_generators(self):
603603

604604
class ElementMethods:
605605

606-
def is_central(self):
606+
def is_central(self) -> bool:
607607
r"""
608608
Return whether the element ``self`` is central.
609609

src/sage/combinat/partition_kleshchev.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ def mullineux_conjugate(self):
428428
KP = mu.parent()
429429
return KP.element_class(KP, mu.add_cell(*mu.cogood_cells( r-c-self.parent()._multicharge[0]) ))
430430

431-
def is_regular(self):
431+
def is_regular(self) -> bool:
432432
r"""
433433
Return ``True`` if ``self`` is a `e`-regular partition tuple.
434434
@@ -454,7 +454,7 @@ def is_regular(self):
454454
KP = self.parent()
455455
return super().is_regular(KP._e, KP._multicharge)
456456

457-
def is_restricted(self):
457+
def is_restricted(self) -> bool:
458458
r"""
459459
Return ``True`` if ``self`` is an `e`-restricted partition tuple.
460460
@@ -811,7 +811,7 @@ def mullineux_conjugate(self):
811811
KP = mu.parent()
812812
return KP.element_class(KP, mu.add_cell(*mu.cogood_cells( r-c-self.parent()._multicharge[k])))
813813

814-
def is_regular(self):
814+
def is_regular(self) -> bool:
815815
r"""
816816
Return ``True`` if ``self`` is a `e`-regular partition tuple.
817817
@@ -835,7 +835,7 @@ def is_regular(self):
835835
KP = self.parent()
836836
return _is_regular(self.to_list(), KP._multicharge, KP._convention)
837837

838-
def is_restricted(self):
838+
def is_restricted(self) -> bool:
839839
r"""
840840
Return ``True`` if ``self`` is an `e`-restricted partition tuple.
841841

src/sage/combinat/root_system/reflection_group_complex.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ def discriminant_in_invariant_ring(self, invariants=None):
852852
return sum(coeffs[i] * mons[i] for i in range(m))
853853

854854
@cached_method
855-
def is_crystallographic(self):
855+
def is_crystallographic(self) -> bool:
856856
r"""
857857
Return ``True`` if ``self`` is crystallographic.
858858
@@ -890,9 +890,10 @@ def is_crystallographic(self):
890890
sage: W.is_crystallographic()
891891
False
892892
"""
893-
return self.is_real() and all(t.to_matrix().base_ring() is QQ for t in self.simple_reflections())
893+
return self.is_real() and all(t.to_matrix().base_ring() is QQ
894+
for t in self.simple_reflections())
894895

895-
def number_of_irreducible_components(self):
896+
def number_of_irreducible_components(self) -> int:
896897
r"""
897898
Return the number of irreducible components of ``self``.
898899
@@ -908,7 +909,7 @@ def number_of_irreducible_components(self):
908909
"""
909910
return len(self._type)
910911

911-
def irreducible_components(self):
912+
def irreducible_components(self) -> list:
912913
r"""
913914
Return a list containing the irreducible components of ``self``
914915
as finite reflection groups.

src/sage/combinat/species/structure.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,10 @@ def _relabel(self, i):
182182
[1, 2, 3]
183183
"""
184184
if isinstance(i, (int, Integer)):
185-
return self._labels[i-1]
186-
else:
187-
return i
185+
return self._labels[i - 1]
186+
return i
188187

189-
def is_isomorphic(self, x):
188+
def is_isomorphic(self, x) -> bool:
190189
"""
191190
EXAMPLES::
192191
@@ -203,7 +202,7 @@ def is_isomorphic(self, x):
203202
if self.parent() != x.parent():
204203
return False
205204

206-
#We don't care about the labels for isomorphism testing
205+
# We don't care about the labels for isomorphism testing
207206
return self.canonical_label()._list == x.canonical_label()._list
208207

209208

src/sage/combinat/subword_complex.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def root_configuration(self):
349349
Phi = self.parent().group().roots()
350350
return [Phi[i] for i in self._root_configuration_indices()]
351351

352-
def kappa_preimage(self):
352+
def kappa_preimage(self) -> list:
353353
r"""
354354
Return the fiber of ``self`` under the `\kappa` map.
355355
@@ -403,7 +403,7 @@ def kappa_preimage(self):
403403
if all(w.action_on_root_indices(i, side='left') < N
404404
for i in root_conf)]
405405

406-
def is_vertex(self):
406+
def is_vertex(self) -> bool:
407407
r"""
408408
Return ``True`` if ``self`` is a vertex of the brick polytope
409409
of ``self.parent``.
@@ -1445,7 +1445,7 @@ def greedy_facet(self, side='positive'):
14451445

14461446
# topological properties
14471447

1448-
def is_sphere(self):
1448+
def is_sphere(self) -> bool:
14491449
r"""
14501450
Return ``True`` if the subword complex ``self`` is a sphere.
14511451
@@ -1472,7 +1472,7 @@ def is_sphere(self):
14721472
w = W.demazure_product(self._Q)
14731473
return w == self._pi
14741474

1475-
def is_ball(self):
1475+
def is_ball(self) -> bool:
14761476
r"""
14771477
Return ``True`` if the subword complex ``self`` is a ball.
14781478
@@ -1499,7 +1499,7 @@ def is_ball(self):
14991499
"""
15001500
return not self.is_sphere()
15011501

1502-
def is_pure(self):
1502+
def is_pure(self) -> bool:
15031503
r"""
15041504
Return ``True`` since all subword complexes are pure.
15051505
@@ -1541,7 +1541,7 @@ def dimension(self):
15411541
# root and weight
15421542

15431543
@cached_method
1544-
def is_root_independent(self):
1544+
def is_root_independent(self) -> bool:
15451545
r"""
15461546
Return ``True`` if ``self`` is root-independent.
15471547
@@ -1569,7 +1569,7 @@ def is_root_independent(self):
15691569
return M.rank() == max(M.ncols(), M.nrows())
15701570

15711571
@cached_method
1572-
def is_double_root_free(self):
1572+
def is_double_root_free(self) -> bool:
15731573
r"""
15741574
Return ``True`` if ``self`` is double-root-free.
15751575

src/sage/dynamics/arithmetic_dynamics/wehlerK3.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def __init__(self, polys):
142142
vars = R.variable_names()
143143
A = ProductProjectiveSpaces([2, 2],R.base_ring(),vars)
144144
CR = A.coordinate_ring()
145-
#Check for following:
145+
# Check for following:
146146
# Is the user calling in 2 polynomials from a list or tuple?
147147
# Is there one biquadratic and one bilinear polynomial?
148148
if len(polys) != 2:
@@ -411,7 +411,7 @@ def Hpoly(self, component, i, j):
411411
sage: X.Hpoly(0, 1, 0)
412412
2*y0*y1^3 + 2*y0*y1*y2^2 - y1*y2^3
413413
"""
414-
#Check Errors in Passed in Values
414+
# Check Errors in Passed in Values
415415
if component not in [0, 1]:
416416
raise ValueError("component can only be 1 or 0")
417417

@@ -709,7 +709,7 @@ def Ramification_poly(self, i):
709709
4*((self._Lcoeff(i, 2))**2)*(self._Qcoeff(i, 1, 1))*(self._Qcoeff(i, 0, 0))
710710

711711
@cached_method
712-
def is_degenerate(self):
712+
def is_degenerate(self) -> bool:
713713
r"""
714714
Function will return ``True`` if there is a fiber (over the algebraic closure of the
715715
base ring) of dimension greater than 0 and ``False`` otherwise.
@@ -751,7 +751,7 @@ def is_degenerate(self):
751751
PP = self.ambient_space()
752752
K = FractionField(PP[0].base_ring())
753753
R = PP.coordinate_ring()
754-
PS = PP[0] #check for x fibers
754+
PS = PP[0] # check for x fibers
755755
vars = list(PS.gens())
756756
R0 = PolynomialRing(K, 3, vars) #for dimension calculation to work,
757757
#must be done with Polynomial ring over a field
@@ -763,7 +763,7 @@ def is_degenerate(self):
763763
if I.dimension() != 0:
764764
return True
765765

766-
PS = PP[1] #check for y fibers
766+
PS = PP[1] # check for y fibers
767767
vars = list(PS.gens())
768768
R0 = PolynomialRing(K,3,vars) #for dimension calculation to work,
769769
#must be done with Polynomial ring over a field
@@ -840,7 +840,7 @@ def degenerate_fibers(self):
840840
phi = R.hom(vars + [0, 0, 0], R0)
841841
I = phi(I)
842842
xFibers = []
843-
#check affine charts
843+
# check affine charts
844844
for n in range(3):
845845
affvars = list(R0.gens())
846846
del affvars[n]
@@ -871,7 +871,7 @@ def degenerate_fibers(self):
871871
phi = PP.coordinate_ring().hom([0, 0, 0] + vars, R0)
872872
I = phi(I)
873873
yFibers = []
874-
#check affine charts
874+
# check affine charts
875875
for n in range(3):
876876
affvars = list(R0.gens())
877877
del affvars[n]
@@ -898,7 +898,7 @@ def degenerate_fibers(self):
898898
@cached_method
899899
def degenerate_primes(self, check=True):
900900
r"""
901-
Determine which primes `p` ``self`` has degenerate fibers over `\GF{p}`.
901+
Determine primes `p` such that ``self`` has degenerate fibers over `\GF{p}`.
902902
903903
If ``check`` is ``False``, then may return primes that do not have degenerate fibers.
904904
Raises an error if the surface is degenerate.
@@ -995,7 +995,7 @@ def degenerate_primes(self, check=True):
995995
if power == 1:
996996
bad_primes = bad_primes+GB[i].lt().coefficients()[0].support()
997997
bad_primes = sorted(set(bad_primes))
998-
#check to return only the truly bad primes
998+
# check to return only the truly bad primes
999999
if check:
10001000
for p in bad_primes:
10011001
X = self.change_ring(GF(p))
@@ -1041,7 +1041,7 @@ def is_smooth(self) -> bool:
10411041
R = self.ambient_space().coordinate_ring()
10421042
I = R.ideal(M.minors(2) + [self.L,self.Q])
10431043
T = PolynomialRing(self.ambient_space().base_ring().fraction_field(), 4, 'h')
1044-
#check the 9 affine charts for a singular point
1044+
# check the 9 affine charts for a singular point
10451045
for l in xmrange([3, 3]):
10461046
vars = list(T.gens())
10471047
vars.insert(l[0], 1)
@@ -1577,7 +1577,7 @@ def phi(self, a, **kwds):
15771577
(-1 : 0 : 1 , 0 : 1 : 0)
15781578
"""
15791579
A = self.sigmaX(a, **kwds)
1580-
kwds.update({"check":False})
1580+
kwds.update({"check": False})
15811581
return self.sigmaY(A, **kwds)
15821582

15831583
def psi(self, a, **kwds):
@@ -1617,7 +1617,7 @@ def psi(self, a, **kwds):
16171617
(0 : 0 : 1 , 0 : 1 : 0)
16181618
"""
16191619
A = self.sigmaY(a, **kwds)
1620-
kwds.update({"check":False})
1620+
kwds.update({"check": False})
16211621
return self.sigmaX(A, **kwds)
16221622

16231623
def lambda_plus(self, P, v, N, m, n, prec=100):
@@ -2411,9 +2411,9 @@ def orbit_psi(self, P, N, **kwds):
24112411
Orb.append(Q)
24122412
return Orb
24132413

2414-
def is_isomorphic(self, right):
2414+
def is_isomorphic(self, right) -> bool:
24152415
r"""
2416-
Check to see if two K3 surfaces have the same defining ideal.
2416+
Check whether two K3 surfaces have the same defining ideal.
24172417
24182418
INPUT:
24192419
@@ -2449,10 +2449,12 @@ def is_isomorphic(self, right):
24492449
"""
24502450
return self.defining_ideal() == right.defining_ideal()
24512451

2452-
def is_symmetric_orbit(self, orbit):
2452+
def is_symmetric_orbit(self, orbit) -> bool:
24532453
r"""
2454-
Check to see if the orbit is symmetric (i.e. if one of the points on the
2455-
orbit is fixed by '\sigma_x' or '\sigma_y').
2454+
Check whether the orbit is symmetric.
2455+
2456+
This means that one of the points on the
2457+
orbit is fixed by '\sigma_x' or '\sigma_y'.
24562458
24572459
INPUT:
24582460

0 commit comments

Comments
 (0)