Example #1
0
    def has_element(self, elem: MathObject) -> bool:
        """Return ``True`` if ``elem`` is an element of this ``Multiset``. ``elem`` must be a `MathObject`.

        For a more relaxed version (that auto-converts non-`MathObject` arguments into instances of
        :class:`~.Atom`) see `__contains__` and the construct ``elem in Multiset``.
        """
        raise_if_not_mathobject(elem)
        return elem in self.data
Example #2
0
 def get_multiplicity(self, elem: MathObject) -> int:
     """Return ``int`` if ``elem`` is an element of this ``Multiset`` where the value is the
     number of multiples for ``elem``. ``elem`` must be a `MathObject`.
     """
     raise_if_not_mathobject(elem)
     return self.data[elem]