Skip to content

Commit

Permalink
Docstring edits
Browse files Browse the repository at this point in the history
Remove excessive blank lines around INPUT, OUTPUT, EXAMPLES, and before
docstring ending """. (#3)
  • Loading branch information
gmou3 committed Jun 13, 2024
1 parent d41de45 commit a2e9564
Show file tree
Hide file tree
Showing 109 changed files with 0 additions and 412 deletions.
1 change: 0 additions & 1 deletion src/sage/combinat/affine_permutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ def __mul__(self, q):
Type A affine permutation with window [-1, 3, 0, 6, 5, 4, 10, 9]
sage: p.apply_simple_reflection(1, 'right')
Type A affine permutation with window [-1, 3, 0, 6, 5, 4, 10, 9]
"""
return self.__rmul__(q)

Expand Down
4 changes: 0 additions & 4 deletions src/sage/combinat/alternating_sign_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,6 @@ def to_fully_packed_loop(self):
+ -- + +
| |
| |
"""
from sage.combinat.fully_packed_loop import FullyPackedLoop
return FullyPackedLoop(self)
Expand Down Expand Up @@ -777,7 +776,6 @@ def ASM_compatible_smaller(self):
[1 0]
[0 1]
]
"""
n = self.parent()._n
M = AlternatingSignMatrices(n-1)
Expand Down Expand Up @@ -1547,7 +1545,6 @@ def cover_relations(self):
[0 0 1] [0 1 0]
[1 0 0], [1 0 0]
)
"""
return iter(self._lattice_initializer()[1])

Expand All @@ -1562,7 +1559,6 @@ def lattice(self):
sage: L = A.lattice()
sage: L
Finite lattice containing 7 elements
"""
return LatticePoset(self._lattice_initializer(), cover_relations=True,
check=False)
Expand Down
27 changes: 0 additions & 27 deletions src/sage/combinat/bijectionist.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,6 @@ class Bijectionist(SageObject):
:meth:`set_statistics`, :meth:`set_intertwining_relations`,
:meth:`set_constant_blocks`, etc., is irrelevant. Calling any of these
methods a second time overrides the previous specification.
"""
def __init__(self, A, B, tau=None, alpha_beta=tuple(), P=None,
pi_rho=tuple(), phi_psi=tuple(), Q=None,
Expand Down Expand Up @@ -605,7 +604,6 @@ def set_constant_blocks(self, P):
Traceback (most recent call last):
...
StopIteration
"""
self._bmilp = None
self._P = DisjointSet(self._A)
Expand Down Expand Up @@ -645,7 +643,6 @@ def constant_blocks(self, singletons=False, optimal=False):
sage: bij.constant_blocks(singletons=True)
{{'a', 'b'}, {'c'}}
"""
if optimal:
self._forced_constant_blocks()
Expand Down Expand Up @@ -748,7 +745,6 @@ def set_statistics(self, *alpha_beta):
{[]: 2, [1]: 0, [1, 2]: 0, [2, 1]: 1}
{[]: 2, [1]: 0, [1, 2]: 1, [2, 1]: 0}
{[]: 2, [1]: 1, [1, 2]: 0, [2, 1]: 0}
"""
self._bmilp = None
self._n_statistics = len(alpha_beta)
Expand Down Expand Up @@ -815,7 +811,6 @@ def statistics_fibers(self):
(3, 2, 1) [[1, 3, 2], [2, 1, 3], [3, 2, 1]] [[1, 3, 2], [2, 1, 3], [2, 3, 1]]
(3, 2, 0) [[2, 3, 1]] [[3, 1, 2]]
(3, 1, 0) [[3, 1, 2]] [[1, 2, 3]]
"""
return self._statistics_fibers

Expand Down Expand Up @@ -940,7 +935,6 @@ def statistics_table(self, header=True):
[['b', 'τ'], [[], 0], [[1], 1], [[1, 2], 2], [[2, 1], 1]]
sage: bij.statistics_table(header=False)[1]
[[[], 0], [[1], 1], [[1, 2], 2], [[2, 1], 1]]
"""
# table for alpha
n_statistics = self._n_statistics
Expand Down Expand Up @@ -1059,7 +1053,6 @@ def set_value_restrictions(self, *value_restrictions):
Traceback (most recent call last):
...
AssertionError: element (1, 2) was not found in A
"""
# it might be much cheaper to construct the sets as subsets
# of _statistics_possible_values - however, we do not want to
Expand Down Expand Up @@ -1091,7 +1084,6 @@ def _compute_possible_block_values(self):
Traceback (most recent call last):
...
ValueError: no possible values found for singleton block [[1, 2]]
"""
self._possible_block_values = {} # P -> Power(Z)
for p, block in self._P.root_to_elements_dict().items():
Expand Down Expand Up @@ -1254,7 +1246,6 @@ def set_distributions(self, *elements_distributions):
Note that the same error occurs when an element that is not the first element of the list is
not in `A`.
"""
self._bmilp = None
for tA, tZ in elements_distributions:
Expand Down Expand Up @@ -1382,7 +1373,6 @@ def set_intertwining_relations(self, *pi_rho):
sage: bij.set_intertwining_relations((2, concat, lambda x, y: x + y), (2, skew_concat, lambda x, y: x + y))
sage: list(bij.solutions_iterator())
[]
"""
self._bmilp = None
Pi_Rho = namedtuple("Pi_Rho", "numargs pi rho domain")
Expand Down Expand Up @@ -1446,7 +1436,6 @@ def set_quadratic_relation(self, *phi_psi):
( [ /\ ] ) ]
( [ / \ ] ) ]
( [ / \ ], [ /\/\/\ ] ) ]
"""
self._bmilp = None
self._phi_psi = phi_psi
Expand All @@ -1467,7 +1456,6 @@ def set_homomesic(self, Q):
sage: bij.set_homomesic([[1,2], [3]])
sage: list(bij.solutions_iterator())
[{1: 2, 2: 0, 3: 1}, {1: 0, 2: 2, 3: 1}]
"""
self._bmilp = None
if Q is None:
Expand Down Expand Up @@ -1639,7 +1627,6 @@ def _forced_constant_blocks(self):
{{'a', 'b'}}
sage: bij.constant_blocks(optimal=True)
{{'a', 'b'}, {'c', 'd'}}
"""
if self._bmilp is None:
self._bmilp = _BijectionistMILP(self)
Expand Down Expand Up @@ -1928,7 +1915,6 @@ def _find_counterexample(self, P, s0, d, on_blocks):
sage: d = {'a': 1, 'b': 0, 'c': 0, 'd': 0, 'e': 0}
sage: bij._find_counterexample(bij._A, s0, d, False)
{'a': 2, 'b': 2, 'c': 1, 'd': 3, 'e': 1}
"""
bmilp = self._bmilp
for z in self._Z:
Expand Down Expand Up @@ -2064,7 +2050,6 @@ def minimal_subdistributions_blocks_iterator(self):
sage: sorted(D) in [d for d, _ in bij.minimal_subdistributions_iterator()]
True
"""
# see
# https://mathoverflow.net/questions/406751/find-a-subdistribution/406975
Expand Down Expand Up @@ -2167,7 +2152,6 @@ def _preprocess_intertwining_relations(self):
sage: bij._preprocess_intertwining_relations()
sage: bij._P
{{[1, 2, 3]}, {[1, 3, 2]}, {[2, 1, 3]}, {[2, 3, 1]}, {[3, 1, 2]}, {[3, 2, 1]}}
"""
A = self._A
P = self._P
Expand Down Expand Up @@ -2446,7 +2430,6 @@ def solutions_iterator(self):
sage: s1_3 = next(iterator1)
sage: len(set([tuple(sorted(s.items())) for s in [s1_1, s1_2, s1_3]]))
3
"""
if self._bmilp is None:
self._bmilp = _BijectionistMILP(self)
Expand Down Expand Up @@ -2485,7 +2468,6 @@ def __init__(self, bijectionist: Bijectionist, solutions=None):
sage: from sage.combinat.bijectionist import _BijectionistMILP
sage: _BijectionistMILP(bij)
<sage.combinat.bijectionist._BijectionistMILP object at ...>
"""
# the attributes of the bijectionist class we actually use:
# _possible_block_values
Expand Down Expand Up @@ -2549,7 +2531,6 @@ def show(self, variables=True):
x_1: s(a) = s(b) = 1
x_2: s(c) = 0
x_3: s(c) = 1
"""
print("Constraints are:")
b = self.milp.get_backend()
Expand Down Expand Up @@ -2608,7 +2589,6 @@ def _prepare_solution(self, on_blocks, solution):
sage: bmilp = bij._bmilp
sage: bmilp._prepare_solution(True, bmilp._solution_cache[0])
{'a': 0, 'c': 0}
"""
P = self._bijectionist._P
tZ = self._bijectionist._possible_block_values
Expand Down Expand Up @@ -2652,7 +2632,6 @@ def solutions_iterator(self, on_blocks, additional_constraints):
{'a': 0, 'b': 0, 'c': 1}
sage: next(it)
{'a': 1, 'b': 0, 'c': 0}
"""
i = 0 # the first unconsidered element of _solution_cache
while True:
Expand Down Expand Up @@ -2721,7 +2700,6 @@ def _add_solution(self, solution):
x_1: s(a) = a
x_2: s(b) = b
x_3: s(b) = a
"""
active_vars = [self._x[p, z]
for p in _disjoint_set_roots(self._bijectionist._P)
Expand Down Expand Up @@ -2855,7 +2833,6 @@ def add_distribution_constraints(self):
[2, 3, 1]: 2,
[3, 1, 2]: 2,
[3, 2, 1]: 2}
"""
Z = self._bijectionist._Z
Z_dict = {z: i for i, z in enumerate(Z)}
Expand Down Expand Up @@ -2997,7 +2974,6 @@ def add_quadratic_relation_constraints(self):
( [ /\ ] ) ]
( [ / \ ] ) ]
( [ / \ ], [ /\/\/\ ] ) ]
"""
P = self._bijectionist._P
for phi, psi in self._bijectionist._phi_psi:
Expand Down Expand Up @@ -3114,7 +3090,6 @@ def _non_copying_intersection(sets):
sage: A = set([1,2]); B = set([2,3])
sage: _non_copying_intersection([A, B])
{2}
"""
sets = sorted(sets, key=len)
result = set.intersection(*sets)
Expand All @@ -3125,8 +3100,6 @@ def _non_copying_intersection(sets):
return result
if s == result:
return s


"""

This comment has been minimized.

Copy link
@kwankyu

kwankyu Jun 18, 2024

Collaborator

No blank line above line 3103? I am not sure here. Please check again.

This comment has been minimized.

Copy link
@gmou3

gmou3 Jun 18, 2024

Author Contributor

this resulted in a lint error and I've already fixed it

TESTS::
Expand Down
7 changes: 0 additions & 7 deletions src/sage/combinat/binary_recurrence_sequences.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@


class BinaryRecurrenceSequence(SageObject):

"""
Create a linear binary recurrence sequence defined by initial conditions
`u_0` and `u_1` and recurrence relation `u_{n+2} = b*u_{n+1}+c*u_n`.
Expand Down Expand Up @@ -104,7 +103,6 @@ class BinaryRecurrenceSequence(SageObject):
sage: R
Binary recurrence sequence defined by: u_n = 3 * u_{n-1} + 3 * u_{n-2};
With initial conditions: u_0 = 2, and u_1 = 1
"""

def __init__(self, b, c, u0=0, u1=1):
Expand All @@ -121,7 +119,6 @@ def __init__(self, b, c, u0=0, u1=1):
sage: R = BinaryRecurrenceSequence(1,1)
sage: loads(R.dumps()) == R
True
"""
self.b = b
self.c = c
Expand All @@ -141,7 +138,6 @@ def __repr__(self):
sage: R
Binary recurrence sequence defined by: u_n = 3 * u_{n-1} + 3 * u_{n-2};
With initial conditions: u_0 = 2, and u_1 = 1
"""
return 'Binary recurrence sequence defined by: u_n = ' + str(self.b) + ' * u_{n-1} + ' + str(self.c) + ' * u_{n-2};\nWith initial conditions: u_0 = ' + str(self.u0) + ', and u_1 = ' + str(self.u1)

Expand Down Expand Up @@ -858,7 +854,6 @@ def _next_good_prime(p, R, qq, patience, qqold):
29
sage: sage.combinat.binary_recurrence_sequences._next_good_prime(7,R,2,100,2) #ran out of patience, as qqold == qq, so no primes work
False
"""

#We are looking for pth powers in R.
Expand Down Expand Up @@ -947,7 +942,6 @@ def _is_p_power_mod(a, p, N):
False
sage: sage.combinat.binary_recurrence_sequences._is_p_power_mod(2**3,3,29)
True
"""

#By the chinese remainder theorem, we can answer this question by examining whether
Expand Down Expand Up @@ -1048,7 +1042,6 @@ def _estimated_time(M2, M1, length, p):
sage: from sage.combinat.binary_recurrence_sequences import _estimated_time
sage: _estimated_time(2**4*3**2*5*7*11*13*17, 2**4*3**2*5*7*11*13, 20, 7) # needs sage.symbolic
106.211159309421
"""

#The heuristic run time of the CRT step to go from modulus M1 to M2
Expand Down
1 change: 0 additions & 1 deletion src/sage/combinat/binary_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -3705,7 +3705,6 @@ def to_full(self):
sage: BinaryTree(None).to_full()
[., .]
"""
if self.is_empty():
return BinaryTree("[.,.]")
Expand Down
1 change: 0 additions & 1 deletion src/sage/combinat/combinat.py
Original file line number Diff line number Diff line change
Expand Up @@ -1415,7 +1415,6 @@ def __bool__(self) -> bool:
sage: b = Bar([4])
sage: not b
False
"""
return bool(self._list)

Expand Down
1 change: 0 additions & 1 deletion src/sage/combinat/combinatorial_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ def combinatorial_map_wrapper(f=None, order=None, name=None):
<function major_index at ...>
sage: combinatorial_map(major_index)
Combinatorial map: major_index
"""
if f is None:
return lambda f: CombinatorialMap(f, order=order, name=name)
Expand Down
1 change: 0 additions & 1 deletion src/sage/combinat/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,6 @@ def __init__(self, k, n):
sage: C = Cores(3, 4)
sage: TestSuite(C).run()
"""
self.k = k
self.n = n
Expand Down
3 changes: 0 additions & 3 deletions src/sage/combinat/decorated_permutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def __classcall_private__(cls, pi):
sage: hash(elt1) # random
915443076393556996
"""
pi = list(pi)
return DecoratedPermutations(len(pi))(pi)
Expand Down Expand Up @@ -148,7 +147,6 @@ class DecoratedPermutations(UniqueRepresentation, Parent):
Decorated permutations of size 3
sage: S.cardinality()
16
"""

def __init__(self, n):
Expand Down Expand Up @@ -230,7 +228,6 @@ def _an_element_(self):
sage: S = DecoratedPermutations(3)
sage: S._an_element_()
[1, 2, 3]
"""
return self.element_class(self, list(range(1, self._n + 1)))

Expand Down
1 change: 0 additions & 1 deletion src/sage/combinat/diagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,6 @@ class Diagrams(UniqueRepresentation, Parent):
sage: D = Dgms([(0,0), (0,3), (2,2), (2,4)])
sage: D.parent()
Combinatorial diagrams
"""

def __init__(self, category=None):
Expand Down
1 change: 0 additions & 1 deletion src/sage/combinat/diagram_algebras.py
Original file line number Diff line number Diff line change
Expand Up @@ -1499,7 +1499,6 @@ def __contains__(self, obj):
sage: bd = da.BrauerDiagrams(3/2)
sage: bd.an_element() in bd
True
"""
if self.order in ZZ:
r = ZZ(self.order)
Expand Down
2 changes: 0 additions & 2 deletions src/sage/combinat/dyck_word.py
Original file line number Diff line number Diff line change
Expand Up @@ -1215,7 +1215,6 @@ def ascent_prime_decomposition(self) -> list[DyckWord]:
sage: DyckWord([1,0,1,0]).ascent_prime_decomposition()
[[], [1, 0], [], [1, 0], []]
"""
n = self.length()
H = self.heights()
Expand Down Expand Up @@ -3013,7 +3012,6 @@ def bounce_path(self) -> DyckWord:
[]
sage: DyckWord([1,0]).bounce_path()
[1, 0]
"""
area_seq = self.to_area_sequence()
i = len(area_seq) - 1
Expand Down
Loading

3 comments on commit a2e9564

@kwankyu
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

It seem that many authors like to put blank lines surrounding a list or a code example. When we later recommend developers to omit blank line following a block at the end of the text, someone may object. Let's see.

@gmou3
Copy link
Contributor Author

@gmou3 gmou3 commented on a2e9564 Jun 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is important to have a binding decision upon such points. This improves consistency and makes the whole Sage project look more professional (and it inspires more serious work from developers and users). Consistency also has other practical benefits: it makes bulk changes easier as you don't need to search for weird formats and patterns.

Ideally, docstrings should pass through a script.

@kwankyu
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree.

Please sign in to comment.