def _element_constructor_(self, x): """ Coerce x into self. EXAMPLES:: sage: X = SchubertPolynomialRing(QQ) sage: X._element_constructor_([2,1,3]) X[2, 1] sage: X._element_constructor_(Permutation([2,1,3])) X[2, 1] :: sage: R.<x1, x2, x3> = QQ[] sage: X(x1^2*x2) X[3, 2, 1] """ if isinstance(x, list): perm = permutation.Permutation_class(x).remove_extra_fixed_points() return self._from_dict({ perm: self.base_ring()(1) }) elif isinstance(x, permutation.Permutation_class): perm = x.remove_extra_fixed_points() return self._from_dict({ perm: self.base_ring()(1) }) elif is_MPolynomial(x): return symmetrica.t_POLYNOM_SCHUBERT(x) else: raise TypeError
def _element_constructor_(self, x): """ Coerce x into self. EXAMPLES:: sage: X = SchubertPolynomialRing(QQ) sage: X._element_constructor_([2,1,3]) X[2, 1] sage: X._element_constructor_(Permutation([2,1,3])) X[2, 1] :: sage: R.<x1, x2, x3> = QQ[] sage: X(x1^2*x2) X[3, 2, 1] """ if isinstance(x, list): perm = permutation.Permutation_class(x).remove_extra_fixed_points() return self._from_dict({perm: self.base_ring()(1)}) elif isinstance(x, permutation.Permutation_class): perm = x.remove_extra_fixed_points() return self._from_dict({perm: self.base_ring()(1)}) elif is_MPolynomial(x): return symmetrica.t_POLYNOM_SCHUBERT(x) else: raise TypeError
def _element_constructor_(self, x): """ Coerce x into self. EXAMPLES:: sage: X = SchubertPolynomialRing(QQ) sage: X._element_constructor_([2,1,3]) X[2, 1] sage: X._element_constructor_(Permutation([2,1,3])) X[2, 1] sage: R.<x1, x2, x3> = QQ[] sage: X(x1^2*x2) X[3, 2, 1] TESTS: We check that :trac:`12924` is fixed:: sage: X = SchubertPolynomialRing(QQ) sage: X._element_constructor_([1,2,1]) Traceback (most recent call last): ... ValueError: The input [1, 2, 1] is not a valid permutation """ if isinstance(x, list): #checking the input to avoid symmetrica crashing Sage, see trac 12924 if not x in Permutations(): raise ValueError, "The input %s is not a valid permutation" % ( x) perm = permutation.Permutation_class(x).remove_extra_fixed_points() return self._from_dict({perm: self.base_ring()(1)}) elif isinstance(x, permutation.Permutation_class): if not list(x) in Permutations(): raise ValueError, "The input %s is not a valid permutation" % ( x) perm = x.remove_extra_fixed_points() return self._from_dict({perm: self.base_ring()(1)}) elif is_MPolynomial(x): return symmetrica.t_POLYNOM_SCHUBERT(x) else: raise TypeError
def _element_constructor_(self, x): """ Coerce x into self. EXAMPLES:: sage: X = SchubertPolynomialRing(QQ) sage: X._element_constructor_([2,1,3]) X[2, 1] sage: X._element_constructor_(Permutation([2,1,3])) X[2, 1] sage: R.<x1, x2, x3> = QQ[] sage: X(x1^2*x2) X[3, 2, 1] TESTS: We check that :trac:`12924` is fixed:: sage: X = SchubertPolynomialRing(QQ) sage: X._element_constructor_([1,2,1]) Traceback (most recent call last): ... ValueError: The input [1, 2, 1] is not a valid permutation """ if isinstance(x, list): #checking the input to avoid symmetrica crashing Sage, see trac 12924 if not x in Permutations(): raise ValueError("The input %s is not a valid permutation"%(x)) perm = permutation.Permutation(x).remove_extra_fixed_points() return self._from_dict({ perm: self.base_ring()(1) }) elif isinstance(x, permutation.Permutation): if not list(x) in Permutations(): raise ValueError("The input %s is not a valid permutation"%(x)) perm = x.remove_extra_fixed_points() return self._from_dict({ perm: self.base_ring()(1) }) elif is_MPolynomial(x): return symmetrica.t_POLYNOM_SCHUBERT(x) else: raise TypeError