Skip to content

Commit 43bb91f

Browse files
committed
some typing -> bool for is_* methods
1 parent 83b52a7 commit 43bb91f

File tree

21 files changed

+128
-117
lines changed

21 files changed

+128
-117
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: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
@@ -2411,7 +2411,7 @@ 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"""
24162416
Check to see if two K3 surfaces have the same defining ideal.
24172417
@@ -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 to see if 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

src/sage/geometry/hyperplane_arrangement/arrangement.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,7 +1454,7 @@ def has_good_reduction(self, p) -> bool:
14541454
q = a.intersection_poset()
14551455
return p.is_isomorphic(q)
14561456

1457-
def is_linear(self):
1457+
def is_linear(self) -> bool:
14581458
r"""
14591459
Test whether all hyperplanes pass through the origin.
14601460
@@ -1478,7 +1478,7 @@ def is_linear(self):
14781478
"""
14791479
return all(hyperplane.b() == 0 for hyperplane in self)
14801480

1481-
def is_essential(self):
1481+
def is_essential(self) -> bool:
14821482
r"""
14831483
Test whether the hyperplane arrangement is essential.
14841484
@@ -3016,7 +3016,7 @@ def whitney_number(self, k, kind=1):
30163016
return self.whitney_data()[1][0, k]
30173017
raise ValueError('argument out of range')
30183018

3019-
def is_separating_hyperplane(self, region1, region2, hyperplane):
3019+
def is_separating_hyperplane(self, region1, region2, hyperplane) -> bool:
30203020
r"""
30213021
Test whether the ``hyperplane`` separates the given regions.
30223022
@@ -3320,7 +3320,7 @@ def minimal_generated_number(self):
33203320
return i
33213321
return self.n_hyperplanes()
33223322

3323-
def is_formal(self):
3323+
def is_formal(self) -> bool:
33243324
"""
33253325
Return if ``self`` is formal.
33263326
@@ -3410,7 +3410,7 @@ def derivation_module_free_chain(self):
34103410
return construct_free_chain(self)
34113411

34123412
@cached_method(key=lambda self, a: None)
3413-
def is_free(self, algorithm='singular'):
3413+
def is_free(self, algorithm='singular') -> bool:
34143414
r"""
34153415
Return if ``self`` is free.
34163416

src/sage/graphs/generic_graph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14177,7 +14177,7 @@ def degree_sequence(self):
1417714177
"""
1417814178
return sorted(self.degree_iterator(), reverse=True)
1417914179

14180-
def is_regular(self, k=None):
14180+
def is_regular(self, k=None) -> bool:
1418114181
"""
1418214182
Check whether this graph is (`k`-)regular.
1418314183

0 commit comments

Comments
 (0)