@@ -501,7 +501,7 @@ def _coerce_map_from_(self, R):
501
501
502
502
from sage .combinat .schubert_polynomial import SchubertPolynomialRing_xbasis
503
503
if isinstance (R , SchubertPolynomialRing_xbasis ):
504
- return CallableConvertMap ( R , self , self .from_schubert_polynomial )
504
+ return self .from_schubert_polynomial
505
505
506
506
phi = P .coerce_map_from (R )
507
507
if phi is not None :
@@ -660,41 +660,65 @@ def from_schubert_polynomial(self, x):
660
660
661
661
EXAMPLES::
662
662
663
- sage: from sage.combinat.key_polynomial import KeyPolynomialBasis
664
- sage: k = KeyPolynomialBasis(ZZ)
663
+ sage: k = KeyPolynomials(ZZ)
665
664
sage: X = SchubertPolynomialRing(ZZ)
666
665
sage: f = X([2,1,5,4,3])
667
666
sage: k.from_schubert_polynomial(f)
668
667
k[1, 0, 2, 1] + k[2, 0, 2] + k[3, 0, 0, 1]
669
668
sage: k.from_schubert_polynomial(2)
670
669
2*k[]
671
- sage: k(f) #indirect doctest
670
+ sage: k(f)
672
671
k[1, 0, 2, 1] + k[2, 0, 2] + k[3, 0, 0, 1]
673
672
673
+ sage: k = KeyPolynomials(GF(7), 4)
674
+ sage: k.from_schubert_polynomial(f)
675
+ k[1, 0, 2, 1] + k[2, 0, 2, 0] + k[3, 0, 0, 1]
676
+
674
677
TESTS::
675
678
676
- sage: from sage.combinat.key_polynomial import KeyPolynomialBasis
677
- sage: k = KeyPolynomialBasis(ZZ)
679
+ sage: k = KeyPolynomials(ZZ)
678
680
sage: k.from_schubert_polynomial(k([3,2]))
679
681
Traceback (most recent call last):
680
682
...
681
- ValueError: Please provide a Schubert polynomial
683
+ ValueError: not a Schubert polynomial
684
+
685
+ sage: k = KeyPolynomials(ZZ)
686
+ sage: X = SchubertPolynomialRing(ZZ)
687
+ sage: it = iter(Compositions())
688
+ sage: for _ in range(50):
689
+ ....: C = next(it)
690
+ ....: assert k.from_schubert_polynomial(X(k[C])) == k[C], C
691
+
692
+ sage: k = KeyPolynomials(ZZ, 4)
693
+ sage: X = SchubertPolynomialRing(ZZ)
694
+ sage: it = iter(k.basis().keys())
695
+ sage: for _ in range(50):
696
+ ....: C = next(it)
697
+ ....: assert k.from_schubert_polynomial(X(k[C])) == k[C], C
682
698
"""
683
699
if x in self .base_ring ():
684
700
return self (x )
701
+
685
702
from sage .combinat .schubert_polynomial import SchubertPolynomial_class
686
703
if not isinstance (x , SchubertPolynomial_class ):
687
- raise ValueError ('Please provide a Schubert polynomial' )
704
+ raise ValueError ('not a Schubert polynomial' )
688
705
689
706
from sage .combinat .diagram import RotheDiagram
690
- R = KeyPolynomialBasis (self .base_ring ())
691
- out = R .zero ()
707
+ out = self .zero ()
708
+ if self ._k is not None :
709
+ def build_elt (wt ):
710
+ wt = list (wt )
711
+ wt += [0 ] * (self ._k - len (wt ))
712
+ return self [wt ]
713
+ else :
714
+ def build_elt (wt ):
715
+ return self [wt ]
692
716
693
717
for m , c in x .monomial_coefficients ().items ():
694
718
D = RotheDiagram (m )
695
- a = R .zero ()
719
+ a = self .zero ()
696
720
for d in D .peelable_tableaux ():
697
- a += R (d .left_key_tableau ().weight ())
721
+ a += build_elt (d .left_key_tableau ().weight ())
698
722
out += c * a
699
723
700
724
return out
0 commit comments