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

Commit

Permalink
trac 29540 still better code in monomial.py, other details there
Browse files Browse the repository at this point in the history
  • Loading branch information
fchapoton committed Apr 22, 2020
1 parent e119938 commit 9570e17
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/sage/combinat/sf/monomial.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
from . import classical
import sage.libs.symmetrica.all as symmetrica
from sage.rings.integer import Integer
from sage.combinat.partition import Partition
from sage.combinat.partition import Partition, Partitions


_Partitions = Partitions()


class SymmetricFunctionAlgebra_monomial(classical.SymmetricFunctionAlgebra_classical):
Expand Down Expand Up @@ -119,7 +122,7 @@ def _multiply(self, left, right):

# Hack due to symmetrica crashing when both of the
# partitions are the empty partition
if not left_m and not right:
if not left_m and not right_m:
z_elt[left_m] = left_c * right_c
continue

Expand Down Expand Up @@ -160,7 +163,7 @@ def from_polynomial(self, f, check=True):
sage: f = x[0]**2+x[1]**2+x[2]**2
sage: m.from_polynomial(f)
m[2]
sage: f=x[0]^2+x[1]
sage: f = x[0]^2+x[1]
sage: m.from_polynomial(f)
Traceback (most recent call last):
...
Expand All @@ -178,10 +181,9 @@ def is_partition(e):
if not e:
return True
return all(x >= y for x, y in zip(e[:-1], e[1:]))
out = self.sum_of_terms(((Partition(e), c)
for e, c in f.dict().items()
if is_partition(e)),
distinct=True)
out = self._from_dict({_Partitions.element_class(_Partitions, list(e)): c
for e, c in f.dict().items()
if is_partition(e)}, remove_zeros=False)
if check and f != out.expand(f.parent().ngens(),
f.parent().variable_names()):
raise ValueError("%s is not a symmetric polynomial" % f)
Expand Down

0 comments on commit 9570e17

Please sign in to comment.