Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit 2273223

Browse files
committed
Making apply_simple_reflection_* and has_*_descent not use the permutation multiplication convention.
1 parent 1040752 commit 2273223

File tree

1 file changed

+73
-41
lines changed

1 file changed

+73
-41
lines changed

src/sage/combinat/permutation.py

Lines changed: 73 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3012,7 +3012,7 @@ def descents(self, final_descent=False, side='right', positive=False,
30123012
Check that the original error of :trac:`23891` is fixed::
30133013
30143014
sage: Permutations(4)([1,4,3,2]).weak_covers()
3015-
[[1, 4, 2, 3], [1, 3, 4, 2]]
3015+
[[1, 3, 4, 2], [1, 4, 2, 3]]
30163016
"""
30173017
if index_set is None:
30183018
index_set = range(1, len(self))
@@ -6200,11 +6200,11 @@ def __init__(self, n, category=None):
62006200
"""
62016201
TESTS:
62026202
6203-
We skip the reduced word method because it does not respect the
6204-
ordering for multiplication::
6203+
We skip the descent and reduced word methods because they do
6204+
not respect the ordering for multiplication::
62056205
62066206
sage: SP = Permutations(3)
6207-
sage: TestSuite(SP).run(skip='_test_reduced_word')
6207+
sage: TestSuite(SP).run(skip=['_test_reduced_word', '_test_has_descent'])
62086208
62096209
sage: SP.options.mult='r2l'
62106210
sage: TestSuite(SP).run()
@@ -6725,12 +6725,6 @@ def has_left_descent(self, i, mult=None):
67256725
descent of `\pi` is an index `i \in \{ 1, 2, \ldots, n-1 \}`
67266726
satisfying `\pi^{-1}(i) > \pi^{-1}(i+1)`.
67276727
6728-
The optional parameter ``mult`` can be set to ``'l2r'`` or
6729-
``'r2l'``; if so done, it is used instead of the ``mult``
6730-
variable in :meth:`Permutations.options`. Anyone using
6731-
this method in a non-interactive environment is encouraged to
6732-
do so in order to have code behave reliably.
6733-
67346728
.. WARNING::
67356729
67366730
The methods :meth:`descents` and :meth:`idescents` behave
@@ -6740,27 +6734,27 @@ def has_left_descent(self, i, mult=None):
67406734
67416735
.. WARNING::
67426736
6743-
The optional input ``mult`` might disappear once :trac:`14881`
6744-
is fixed.
6737+
This ignores the multiplication convention in order
6738+
to be consistent with other Coxeter operations in
6739+
permutations (e.g., computing :meth:`reduced_word`).
67456740
67466741
EXAMPLES::
67476742
67486743
sage: P = Permutations(4)
67496744
sage: x = P([3, 2, 4, 1])
6750-
sage: x.descents()
6751-
[1, 3]
6745+
sage: (~x).descents()
6746+
[1, 2]
67526747
sage: [i for i in P.index_set() if x.has_left_descent(i)]
6753-
[1, 3]
6754-
sage: [i for i in P.index_set() if x.has_left_descent(i, mult="l2r")]
6755-
[1, 3]
6756-
sage: [i for i in P.index_set() if x.has_left_descent(i, mult="r2l")]
67576748
[1, 2]
67586749
"""
6759-
if mult is None:
6760-
mult = self.parent().options.mult
6761-
if mult != 'l2r':
6762-
self = self.inverse()
6763-
return self[i-1] > self[i]
6750+
if mult is not None:
6751+
from sage.misc.superseded import deprecation
6752+
deprecation(27467, "The mult option is deprecated.")
6753+
for val in self._list:
6754+
if val == i:
6755+
return False
6756+
if val == i + 1:
6757+
return True
67646758

67656759
def has_right_descent(self, i, mult=None):
67666760
r"""
@@ -6783,12 +6777,6 @@ def has_right_descent(self, i, mult=None):
67836777
descent of `\pi` is an index `i \in \{ 1, 2, \ldots, n-1 \}`
67846778
satisfying `\pi(i) > \pi(i+1)`.
67856779
6786-
The optional parameter ``mult`` can be set to ``'l2r'`` or
6787-
``'r2l'``; if so done, it is used instead of the ``mult``
6788-
variable in :meth:`Permutations.options`. Anyone using
6789-
this method in a non-interactive environment is encouraged to
6790-
do so in order to have code behave reliably.
6791-
67926780
.. WARNING::
67936781
67946782
The methods :meth:`descents` and :meth:`idescents` behave
@@ -6798,26 +6786,22 @@ def has_right_descent(self, i, mult=None):
67986786
67996787
.. WARNING::
68006788
6801-
The optional input ``mult`` might disappear once :trac:`14881`
6802-
is fixed.
6789+
This ignores the multiplication convention in order
6790+
to be consistent with other Coxeter operations in
6791+
permutations (e.g., computing :meth:`reduced_word`).
68036792
68046793
EXAMPLES::
68056794
68066795
sage: P = Permutations(4)
68076796
sage: x = P([3, 2, 4, 1])
6808-
sage: (~x).descents()
6809-
[1, 2]
6797+
sage: x.descents()
6798+
[1, 3]
68106799
sage: [i for i in P.index_set() if x.has_right_descent(i)]
6811-
[1, 2]
6812-
sage: [i for i in P.index_set() if x.has_right_descent(i, mult="l2r")]
6813-
[1, 2]
6814-
sage: [i for i in P.index_set() if x.has_right_descent(i, mult="r2l")]
68156800
[1, 3]
68166801
"""
6817-
if mult is None:
6818-
mult = self.parent().options.mult
6819-
if mult != 'r2l':
6820-
self = self.inverse()
6802+
if mult is not None:
6803+
from sage.misc.superseded import deprecation
6804+
deprecation(27467, "The mult option is deprecated.")
68216805
return self[i-1] > self[i]
68226806

68236807
def __mul__(self, other):
@@ -6887,6 +6871,54 @@ def inverse(self):
68876871

68886872
__invert__ = inverse
68896873

6874+
def apply_simple_reflection_left(self, i):
6875+
r"""
6876+
Return ``self`` multiplied by the simple reflection ``s[i]``
6877+
on the left.
6878+
6879+
.. WARNING::
6880+
6881+
This ignores the multiplication convention in order
6882+
to be consistent with other Coxeter operations in
6883+
permutations (e.g., computing :meth:`reduced_word`).
6884+
6885+
EXAMPLES::
6886+
6887+
sage: W = Permutations(3)
6888+
sage: w = W([2,3,1])
6889+
sage: w.apply_simple_reflection_left(1)
6890+
[1, 3, 2]
6891+
sage: w.apply_simple_reflection_left(2)
6892+
[3, 2, 1]
6893+
"""
6894+
s = self.parent().simple_reflections()[i]
6895+
p = right_action_same_n(self._list, s._list)
6896+
return self.__class__(self.parent(), p)
6897+
6898+
def apply_simple_reflection_right(self, i):
6899+
r"""
6900+
Return ``self`` multiplied by the simple reflection ``s[i]``
6901+
on the right.
6902+
6903+
.. WARNING::
6904+
6905+
This ignores the multiplication convention in order
6906+
to be consistent with other Coxeter operations in
6907+
permutations (e.g., computing :meth:`reduced_word`).
6908+
6909+
EXAMPLES::
6910+
6911+
sage: W = Permutations(3)
6912+
sage: w = W([2,3,1])
6913+
sage: w.apply_simple_reflection_right(1)
6914+
[3, 2, 1]
6915+
sage: w.apply_simple_reflection_right(2)
6916+
[2, 1, 3]
6917+
"""
6918+
s = self.parent().simple_reflections()[i]
6919+
p = left_action_same_n(self._list, s._list)
6920+
return self.__class__(self.parent(), p)
6921+
68906922
#############################
68916923
# Constructing Permutations #
68926924
#############################

0 commit comments

Comments
 (0)