Skip to content

Commit 4fd846e

Browse files
author
Release Manager
committed
gh-39578: adding some type annotations in lattices mostly in the many methods with a boolean result ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. URL: #39578 Reported by: Frédéric Chapoton Reviewer(s): Vincent Macri
2 parents 3918083 + 962d64a commit 4fd846e

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

Diff for: src/sage/combinat/posets/lattices.py

+36-36
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ def neutral_elements(self):
916916
t = sorted(self._hasse_diagram.neutral_elements())
917917
return [self._vertex_to_element(v) for v in t]
918918

919-
def is_join_distributive(self, certificate=False):
919+
def is_join_distributive(self, certificate=False) -> bool | tuple:
920920
"""
921921
Return ``True`` if the lattice is join-distributive and ``False``
922922
otherwise.
@@ -1005,7 +1005,7 @@ def is_join_distributive(self, certificate=False):
10051005
diamond = next(self._hasse_diagram.subgraph_search_iterator(M3, return_graphs=False))
10061006
return (False, self[diamond[0]])
10071007

1008-
def is_meet_distributive(self, certificate=False):
1008+
def is_meet_distributive(self, certificate=False) -> bool | tuple:
10091009
"""
10101010
Return ``True`` if the lattice is meet-distributive and ``False``
10111011
otherwise.
@@ -1093,7 +1093,7 @@ def is_meet_distributive(self, certificate=False):
10931093
diamond = next(self._hasse_diagram.subgraph_search_iterator(M3, return_graphs=False))
10941094
return (False, self[diamond[4]])
10951095

1096-
def is_stone(self, certificate=False):
1096+
def is_stone(self, certificate=False) -> bool | tuple:
10971097
r"""
10981098
Return ``True`` if the lattice is a Stone lattice, and ``False``
10991099
otherwise.
@@ -1188,7 +1188,7 @@ def is_stone(self, certificate=False):
11881188

11891189
return ok
11901190

1191-
def is_distributive(self, certificate=False):
1191+
def is_distributive(self, certificate=False) -> bool | tuple:
11921192
r"""
11931193
Return ``True`` if the lattice is distributive, and ``False``
11941194
otherwise.
@@ -1228,7 +1228,7 @@ def is_distributive(self, certificate=False):
12281228
:meth:`is_semidistributive`, :meth:`is_join_distributive`,
12291229
:meth:`is_meet_distributive`, :meth:`is_subdirectly_reducible`,
12301230
:meth:`is_trim`,
1231-
:meth:`is_constructible_by_doublings` (by interval doubling),
1231+
:meth:`is_congruence_uniform`,
12321232
:meth:`is_extremal`
12331233
12341234
- Stronger properties: :meth:`is_stone`
@@ -1262,7 +1262,7 @@ def is_distributive(self, certificate=False):
12621262
self._vertex_to_element(diamond[2]),
12631263
self._vertex_to_element(diamond[3])))
12641264

1265-
def is_semidistributive(self):
1265+
def is_semidistributive(self) -> bool:
12661266
"""
12671267
Return ``True`` if the lattice is both join- and meet-semidistributive,
12681268
and ``False`` otherwise.
@@ -1308,7 +1308,7 @@ def is_semidistributive(self):
13081308
H.out_degree_sequence().count(1)) and
13091309
self.is_meet_semidistributive())
13101310

1311-
def is_meet_semidistributive(self, certificate=False):
1311+
def is_meet_semidistributive(self, certificate=False) -> bool | tuple:
13121312
r"""
13131313
Return ``True`` if the lattice is meet-semidistributive, and ``False``
13141314
otherwise.
@@ -1400,7 +1400,7 @@ def is_meet_semidistributive(self, certificate=False):
14001400
return (True, None)
14011401
return True
14021402

1403-
def is_join_semidistributive(self, certificate=False):
1403+
def is_join_semidistributive(self, certificate=False) -> bool | tuple:
14041404
r"""
14051405
Return ``True`` if the lattice is join-semidistributive, and ``False``
14061406
otherwise.
@@ -1496,7 +1496,7 @@ def is_join_semidistributive(self, certificate=False):
14961496
return all(H.kappa_dual(v) is not None
14971497
for v in H if H.out_degree(v) == 1)
14981498

1499-
def is_extremal(self):
1499+
def is_extremal(self) -> bool:
15001500
"""
15011501
Return ``True`` if the lattice is extremal, and ``False``
15021502
otherwise.
@@ -1526,7 +1526,7 @@ def is_extremal(self):
15261526
mi = len(self.meet_irreducibles())
15271527
return ji == mi == self.height() - 1
15281528

1529-
def is_trim(self, certificate=False):
1529+
def is_trim(self, certificate=False) -> bool | tuple:
15301530
"""
15311531
Return whether a lattice is trim.
15321532
@@ -1575,7 +1575,7 @@ def is_trim(self, certificate=False):
15751575
else:
15761576
return (False, None) if certificate else False
15771577

1578-
def is_complemented(self, certificate=False):
1578+
def is_complemented(self, certificate=False) -> bool | tuple:
15791579
r"""
15801580
Return ``True`` if the lattice is complemented, and
15811581
``False`` otherwise.
@@ -1626,7 +1626,7 @@ def is_complemented(self, certificate=False):
16261626
return (True, None)
16271627
return (False, self._vertex_to_element(e))
16281628

1629-
def is_cosectionally_complemented(self, certificate=False):
1629+
def is_cosectionally_complemented(self, certificate=False) -> bool | tuple:
16301630
"""
16311631
Return ``True`` if the lattice is cosectionally complemented, and
16321632
``False`` otherwise.
@@ -1702,7 +1702,7 @@ def is_cosectionally_complemented(self, certificate=False):
17021702
return False
17031703
return (True, None) if certificate else True
17041704

1705-
def is_relatively_complemented(self, certificate=False):
1705+
def is_relatively_complemented(self, certificate=False) -> bool | tuple:
17061706
"""
17071707
Return ``True`` if the lattice is relatively complemented, and
17081708
``False`` otherwise.
@@ -1815,7 +1815,7 @@ def is_relatively_complemented(self, certificate=False):
18151815
self._vertex_to_element(e3)))
18161816
return (True, None) if certificate else True
18171817

1818-
def is_sectionally_complemented(self, certificate=False):
1818+
def is_sectionally_complemented(self, certificate=False) -> bool | tuple:
18191819
"""
18201820
Return ``True`` if the lattice is sectionally complemented, and
18211821
``False`` otherwise.
@@ -2086,7 +2086,7 @@ def complements(self, element=None):
20862086
if self.meet(x, element) == self.bottom() and
20872087
self.join(x, element) == self.top()]
20882088

2089-
def is_pseudocomplemented(self, certificate=False):
2089+
def is_pseudocomplemented(self, certificate=False) -> bool | tuple:
20902090
r"""
20912091
Return ``True`` if the lattice is pseudocomplemented, and ``False``
20922092
otherwise.
@@ -2153,7 +2153,7 @@ def is_pseudocomplemented(self, certificate=False):
21532153
return (True, None)
21542154
return True
21552155

2156-
def is_join_pseudocomplemented(self, certificate=False):
2156+
def is_join_pseudocomplemented(self, certificate=False) -> bool | tuple:
21572157
"""
21582158
Return ``True`` if the lattice is join-pseudocomplemented, and
21592159
``False`` otherwise.
@@ -2323,7 +2323,7 @@ def is_orthocomplemented(self, unique=False):
23232323
return True
23242324
raise AssertionError("bug in is_orthocomplemented()")
23252325

2326-
def is_atomic(self, certificate=False):
2326+
def is_atomic(self, certificate=False) -> bool | tuple:
23272327
r"""
23282328
Return ``True`` if the lattice is atomic, and ``False`` otherwise.
23292329
@@ -2381,7 +2381,7 @@ def is_atomic(self, certificate=False):
23812381
return (False, self._vertex_to_element(v))
23822382
return (True, None)
23832383

2384-
def is_coatomic(self, certificate=False):
2384+
def is_coatomic(self, certificate=False) -> bool | tuple:
23852385
r"""
23862386
Return ``True`` if the lattice is coatomic, and ``False`` otherwise.
23872387
@@ -2439,7 +2439,7 @@ def is_coatomic(self, certificate=False):
24392439
return (False, self._vertex_to_element(v))
24402440
return (True, None)
24412441

2442-
def is_geometric(self):
2442+
def is_geometric(self) -> bool:
24432443
"""
24442444
Return ``True`` if the lattice is geometric, and ``False`` otherwise.
24452445
@@ -2484,7 +2484,7 @@ def is_geometric(self):
24842484
"""
24852485
return self.is_atomic() and self.is_upper_semimodular()
24862486

2487-
def is_planar(self):
2487+
def is_planar(self) -> bool:
24882488
r"""
24892489
Return ``True`` if the lattice is *upward* planar, and ``False``
24902490
otherwise.
@@ -2549,7 +2549,7 @@ def is_planar(self):
25492549
g.add_edge(0, self.cardinality() - 1)
25502550
return g.is_planar()
25512551

2552-
def is_modular(self, L=None, certificate=False):
2552+
def is_modular(self, L=None, certificate=False) -> bool | tuple:
25532553
r"""
25542554
Return ``True`` if the lattice is modular and ``False`` otherwise.
25552555
@@ -2654,7 +2654,7 @@ def is_modular(self, L=None, certificate=False):
26542654
return (True, None)
26552655
return True
26562656

2657-
def is_modular_element(self, x):
2657+
def is_modular_element(self, x) -> bool:
26582658
r"""
26592659
Return ``True`` if ``x`` is a modular element and ``False`` otherwise.
26602660
@@ -2686,7 +2686,7 @@ def is_modular_element(self, x):
26862686
"""
26872687
return self.is_modular([x])
26882688

2689-
def is_left_modular_element(self, x):
2689+
def is_left_modular_element(self, x) -> bool:
26902690
r"""
26912691
Return ``True`` if ``x`` is a left modular element
26922692
and ``False`` otherwise.
@@ -2719,7 +2719,7 @@ def is_left_modular_element(self, x):
27192719
self.join(y, self.meet(x, z))
27202720
for y, z in self.cover_relations_iterator())
27212721

2722-
def is_upper_semimodular(self, certificate=False):
2722+
def is_upper_semimodular(self, certificate=False) -> bool | tuple:
27232723
r"""
27242724
Return ``True`` if the lattice is upper semimodular and
27252725
``False`` otherwise.
@@ -2779,7 +2779,7 @@ def is_upper_semimodular(self, certificate=False):
27792779
self._vertex_to_element(nonmodular[1])))
27802780
return False
27812781

2782-
def is_lower_semimodular(self, certificate=False):
2782+
def is_lower_semimodular(self, certificate=False) -> bool | tuple:
27832783
r"""
27842784
Return ``True`` if the lattice is lower semimodular and
27852785
``False`` otherwise.
@@ -2834,7 +2834,7 @@ def is_lower_semimodular(self, certificate=False):
28342834
self._vertex_to_element(nonmodular[1])))
28352835
return False
28362836

2837-
def is_supersolvable(self, certificate=False):
2837+
def is_supersolvable(self, certificate=False) -> bool | tuple:
28382838
r"""
28392839
Return ``True`` if the lattice is supersolvable, and
28402840
``False`` otherwise.
@@ -3091,7 +3091,7 @@ def vertical_decomposition(self, elements_only=False):
30913091
elms[i + 1] + 1)]))
30923092
for i in range(n - 1)]
30933093

3094-
def is_vertically_decomposable(self, certificate=False):
3094+
def is_vertically_decomposable(self, certificate=False) -> bool | tuple:
30953095
r"""
30963096
Return ``True`` if the lattice is vertically decomposable, and
30973097
``False`` otherwise.
@@ -3185,7 +3185,7 @@ def sublattice(self, elms):
31853185

31863186
return LatticePoset(self.subposet(current_set))
31873187

3188-
def is_sublattice(self, other):
3188+
def is_sublattice(self, other) -> bool:
31893189
"""
31903190
Return ``True`` if the lattice is a sublattice of ``other``,
31913191
and ``False`` otherwise.
@@ -3683,7 +3683,7 @@ def center(self):
36833683
comps = self.complements()
36843684
return self.sublattice([e for e in neutrals if e in comps])
36853685

3686-
def is_dismantlable(self, certificate=False):
3686+
def is_dismantlable(self, certificate=False) -> bool | tuple:
36873687
r"""
36883688
Return ``True`` if the lattice is dismantlable, and ``False``
36893689
otherwise.
@@ -3798,7 +3798,7 @@ def is_dismantlable(self, certificate=False):
37983798
return True
37993799
return (True, [self[e] for e in cert])
38003800

3801-
def is_interval_dismantlable(self, certificate=False):
3801+
def is_interval_dismantlable(self, certificate=False) -> bool | tuple:
38023802
"""
38033803
Return ``True`` if the lattice is interval dismantlable, and
38043804
``False`` otherwise.
@@ -3911,7 +3911,7 @@ def recursive_is_interval_dismantlable(self):
39113911
return result if certificate else True
39123912
return (False, minimal_non_int_dismant(self)) if certificate else False
39133913

3914-
def is_sublattice_dismantlable(self):
3914+
def is_sublattice_dismantlable(self) -> bool:
39153915
"""
39163916
Return ``True`` if the lattice is sublattice dismantlable, and
39173917
``False`` otherwise.
@@ -3984,7 +3984,7 @@ def is_sublattice_dismantlable(self):
39843984

39853985
return False
39863986

3987-
def is_subdirectly_reducible(self, certificate=False):
3987+
def is_subdirectly_reducible(self, certificate=False) -> bool | tuple:
39883988
r"""
39893989
Return ``True`` if the lattice is subdirectly reducible.
39903990
@@ -4367,7 +4367,7 @@ def is_congruence_uniform(self) -> bool:
43674367
"""
43684368
return self.is_constructible_by_doublings(type="interval")
43694369

4370-
def is_isoform(self, certificate=False):
4370+
def is_isoform(self, certificate=False) -> bool | tuple:
43714371
"""
43724372
Return ``True`` if the lattice is isoform and ``False`` otherwise.
43734373
@@ -4442,7 +4442,7 @@ def is_isoform(self, certificate=False):
44424442
return False
44434443
return ok
44444444

4445-
def is_uniform(self, certificate=False):
4445+
def is_uniform(self, certificate=False) -> bool | tuple:
44464446
"""
44474447
Return ``True`` if the lattice is uniform and ``False`` otherwise.
44484448
@@ -4522,7 +4522,7 @@ def is_uniform(self, certificate=False):
45224522
return False
45234523
return ok
45244524

4525-
def is_regular(self, certificate=False):
4525+
def is_regular(self, certificate=False) -> bool | tuple:
45264526
"""
45274527
Return ``True`` if the lattice is regular and ``False`` otherwise.
45284528
@@ -4590,7 +4590,7 @@ def is_regular(self, certificate=False):
45904590
return False
45914591
return ok
45924592

4593-
def is_simple(self, certificate=False):
4593+
def is_simple(self, certificate=False) -> bool | tuple:
45944594
"""
45954595
Return ``True`` if the lattice is simple and ``False`` otherwise.
45964596

0 commit comments

Comments
 (0)