Skip to content

Commit d12dfe5

Browse files
committed
Trac #21325: use (new) decorator minimize_result
1 parent 4391959 commit d12dfe5

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

src/sage/combinat/k_regular_sequence.py

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696

9797
from .recognizable_series import RecognizableSeries
9898
from .recognizable_series import RecognizableSeriesSpace
99+
from .recognizable_series import minimize_result
99100
from sage.misc.cachefunc import cached_method
100101

101102

@@ -276,7 +277,8 @@ def __iter__(self):
276277
from itertools import count
277278
return iter(self[n] for n in count())
278279

279-
def subsequence(self, a, b, minimize=True):
280+
@minimize_result
281+
def subsequence(self, a, b):
280282
r"""
281283
Return the subsequence with indices `an+b` of this
282284
`k`-regular sequence.
@@ -291,8 +293,10 @@ def subsequence(self, a, b, minimize=True):
291293
`b_j \mapsto c_j`. If so, the result will be the sum
292294
of all `c_j(an+b_j)`.
293295
294-
- ``minimize`` -- (default: ``True``) a boolean. If set, then
295-
:meth:`minimized` is called after the operation.
296+
- ``minimize`` -- (default: ``None``) a boolean or ``None``.
297+
If ``True``, then :meth:`minimized` is called after the operation,
298+
if ``False``, then not. If this argument is ``None``, then
299+
the default specified by the parent's ``minimize_results`` is used.
296300
297301
OUTPUT:
298302
@@ -460,10 +464,7 @@ def mu_line(r, i, c):
460464
if c >= 0 else dim*(zero,)
461465
for c in kernel), tuple())))
462466

463-
if minimize:
464-
return result.minimized()
465-
else:
466-
return result
467+
return result
467468

468469
def backward_differences(self, **kwds):
469470
r"""
@@ -472,8 +473,10 @@ def backward_differences(self, **kwds):
472473
473474
INPUT:
474475
475-
- ``minimize`` -- (default: ``True``) a boolean. If set, then
476-
:meth:`minimized` is called after the operation.
476+
- ``minimize`` -- (default: ``None``) a boolean or ``None``.
477+
If ``True``, then :meth:`minimized` is called after the operation,
478+
if ``False``, then not. If this argument is ``None``, then
479+
the default specified by the parent's ``minimize_results`` is used.
477480
478481
OUTPUT:
479482
@@ -511,8 +514,10 @@ def forward_differences(self, **kwds):
511514
512515
INPUT:
513516
514-
- ``minimize`` -- (default: ``True``) a boolean. If set, then
515-
:meth:`minimized` is called after the operation.
517+
- ``minimize`` -- (default: ``None``) a boolean or ``None``.
518+
If ``True``, then :meth:`minimized` is called after the operation,
519+
if ``False``, then not. If this argument is ``None``, then
520+
the default specified by the parent's ``minimize_results`` is used.
516521
517522
OUTPUT:
518523
@@ -539,7 +544,8 @@ def forward_differences(self, **kwds):
539544
"""
540545
return self.subsequence(1, {1: 1, 0: -1}, **kwds)
541546

542-
def partial_sums(self, include_n=False, minimize=True):
547+
@minimize_result
548+
def partial_sums(self, include_n=False):
543549
r"""
544550
Return the sequence of partial sums of this
545551
`k`-regular sequence. That is, the `n`th entry of the result
@@ -551,8 +557,10 @@ def partial_sums(self, include_n=False, minimize=True):
551557
the `n`th entry of the result is the sum of the entries up
552558
to index `n` (included).
553559
554-
- ``minimize`` -- (default: ``True``) a boolean. If set, then
555-
:meth:`minimized` is called after the operation.
560+
- ``minimize`` -- (default: ``None``) a boolean or ``None``.
561+
If ``True``, then :meth:`minimized` is called after the operation,
562+
if ``False``, then not. If this argument is ``None``, then
563+
the default specified by the parent's ``minimize_results`` is used.
556564
557565
OUTPUT:
558566
@@ -620,10 +628,7 @@ def partial_sums(self, include_n=False, minimize=True):
620628
(dim*(0,) if include_n else tuple(-self.left))),
621629
vector(2*tuple(self.right)))
622630

623-
if minimize:
624-
return result.minimized()
625-
else:
626-
return result
631+
return result
627632

628633

629634
class kRegularSequenceSpace(RecognizableSeriesSpace):

0 commit comments

Comments
 (0)