Skip to content

Commit

Permalink
make MolecularSpecies.__classcall__ sane
Browse files Browse the repository at this point in the history
  • Loading branch information
mantepse committed Nov 7, 2024
1 parent 0ca9a5b commit 4598eda
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/sage/rings/species.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ class MolecularSpecies(IndexedFreeAbelianMonoid):
The monoid of (multivariate) molecular species.
"""
@staticmethod
def __classcall__(cls, *args, **kwds):
def __classcall__(cls, names):
"""
Normalize the arguments.
Expand All @@ -779,17 +779,10 @@ def __classcall__(cls, *args, **kwds):
sage: MolecularSpecies("X,Y") == MolecularSpecies(["X", "Z"])
False
"""
if isinstance(args[0], AtomicSpecies):
indices = args[0]
else:
assert "names" not in kwds or kwds["names"] is None
indices = AtomicSpecies(args[0])
category = Monoids().Commutative() & SetsWithGrading().Infinite()
return super().__classcall__(cls, indices,
prefix='', bracket=False,
category=category)
names = normalize_names(-1, names)
return UniqueRepresentation.__classcall__(cls, names)

def __init__(self, *args, **kwds):
def __init__(self, names):
r"""
Initialize the class of (multivariate) molecular species.
Expand Down Expand Up @@ -817,8 +810,11 @@ def __init__(self, *args, **kwds):
sage: M2 = MolecularSpecies(["X", "Y"])
sage: TestSuite(M2).run(skip="_test_graded_components")
"""
IndexedFreeAbelianMonoid.__init__(self, *args, **kwds)
self._arity = args[0]._arity
indices = AtomicSpecies(names)
category = Monoids().Commutative() & SetsWithGrading().Infinite()
IndexedFreeAbelianMonoid.__init__(self, indices, prefix='',
bracket=False, category=category)
self._arity = indices._arity

def _repr_(self):
r"""
Expand Down

0 comments on commit 4598eda

Please sign in to comment.