multiset


Namemultiset JSON
Version 3.1.0 PyPI version JSON
download
home_pagehttps://github.com/wheerd/multiset
SummaryAn implementation of a multiset.
upload_time2024-04-05 20:49:00
maintainerNone
docs_urlhttps://pythonhosted.org/multiset/
authorManuel Krebber
requires_python>=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            multiset
========

This package provides a multiset_ implementation for python.

|pypi| |coverage| |build| |docs|

Overview
--------

A multiset is similar to the builtin set_, but it allows an element to occur multiple times.
It is an unordered collection of elements which have to be hashable just like in a set_.
It supports the same methods and operations as set_ does, e.g. membership test, union, intersection, and
(symmetric) difference::

    >>> set1 = Multiset('aab')
    >>> set2 = Multiset('abc')
    >>> sorted(set1 | set2)
    ['a', 'a', 'b', 'c']

Multisets can be used in combination with sets_::

    >>> Multiset('aab') >= {'a', 'b'}
    True

Multisets are mutable::

    >>> set1.update('bc')
    >>> sorted(set1)
    ['a', 'a', 'b', 'b', 'c']

There is an immutable version similar to the frozenset_ which is also hashable::

    >>> set1 = FrozenMultiset('abc')
    >>> set2 = FrozenMultiset('abc')
    >>> hash(set1) == hash(set2)
    True
    >>> set1 is set2
    False

The implementation is based on a dict_ that maps the elements to their multiplicity in the multiset.
Hence, some dictionary operations are supported.

In contrast to the `collections.Counter`_ from the standard library, it has proper support for set
operations and only allows positive counts. Also, elements with a zero multiplicity are automatically
removed from the multiset.

Installation
------------

Installing `multiset` is simple with `pip <http://www.pip-installer.org/>`_::

    $ pip install multiset

Documentation
-------------

The documentation is available at `Read the Docs`_.

.. _`Read the Docs`: http://multiset.readthedocs.io/

API Documentation
.................

If you are looking for information on a particular method of the Multiset class, have a look at the
`API Documentation`_. It is automatically generated from the docstrings.

.. _`API Documentation`: http://multiset.readthedocs.io/en/latest/api.html

License
-------

Licensed under the MIT_ license.


.. _multiset: https://en.wikipedia.org/wiki/Multiset
.. _set: https://docs.python.org/3.10/library/stdtypes.html#set-types-set-frozenset
.. _sets: set_
.. _frozenset: set_
.. _dict: https://docs.python.org/3.10/library/stdtypes.html#mapping-types-dict
.. _`collections.Counter`: https://docs.python.org/3.10/library/collections.html#collections.Counter
.. _MIT: https://opensource.org/licenses/MIT


.. |pypi| image:: https://img.shields.io/pypi/v/multiset.svg?style=flat-square&label=latest%20stable%20version
    :target: https://pypi.python.org/pypi/multiset
    :alt: Latest version released on PyPi

.. |coverage| image:: https://coveralls.io/repos/github/wheerd/multiset/badge.svg?branch=master
    :target: https://coveralls.io/github/wheerd/multiset?branch=master
    :alt: Test coverage

.. |build| image:: https://github.com/wheerd/multiset/workflows/Tests/badge.svg?branch=master
    :target: https://github.com/wheerd/multiset/actions?query=workflow%3ATests
    :alt: Build status of the master branch

.. |docs| image:: https://readthedocs.org/projects/multiset/badge/?version=latest
    :target: http://multiset.readthedocs.io/en/latest/?badge=latest
    :alt: Documentation Status

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/wheerd/multiset",
    "name": "multiset",
    "maintainer": null,
    "docs_url": "https://pythonhosted.org/multiset/",
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Manuel Krebber",
    "author_email": "Manuel Krebber <admin@wheerd.de>",
    "download_url": "https://files.pythonhosted.org/packages/ff/87/e9b76cf3225549e6af95b32d0642d1a0364967e8393e66a62ed6244ec8e4/multiset-3.1.0.tar.gz",
    "platform": null,
    "description": "multiset\n========\n\nThis package provides a multiset_ implementation for python.\n\n|pypi| |coverage| |build| |docs|\n\nOverview\n--------\n\nA multiset is similar to the builtin set_, but it allows an element to occur multiple times.\nIt is an unordered collection of elements which have to be hashable just like in a set_.\nIt supports the same methods and operations as set_ does, e.g. membership test, union, intersection, and\n(symmetric) difference::\n\n    >>> set1 = Multiset('aab')\n    >>> set2 = Multiset('abc')\n    >>> sorted(set1 | set2)\n    ['a', 'a', 'b', 'c']\n\nMultisets can be used in combination with sets_::\n\n    >>> Multiset('aab') >= {'a', 'b'}\n    True\n\nMultisets are mutable::\n\n    >>> set1.update('bc')\n    >>> sorted(set1)\n    ['a', 'a', 'b', 'b', 'c']\n\nThere is an immutable version similar to the frozenset_ which is also hashable::\n\n    >>> set1 = FrozenMultiset('abc')\n    >>> set2 = FrozenMultiset('abc')\n    >>> hash(set1) == hash(set2)\n    True\n    >>> set1 is set2\n    False\n\nThe implementation is based on a dict_ that maps the elements to their multiplicity in the multiset.\nHence, some dictionary operations are supported.\n\nIn contrast to the `collections.Counter`_ from the standard library, it has proper support for set\noperations and only allows positive counts. Also, elements with a zero multiplicity are automatically\nremoved from the multiset.\n\nInstallation\n------------\n\nInstalling `multiset` is simple with `pip <http://www.pip-installer.org/>`_::\n\n    $ pip install multiset\n\nDocumentation\n-------------\n\nThe documentation is available at `Read the Docs`_.\n\n.. _`Read the Docs`: http://multiset.readthedocs.io/\n\nAPI Documentation\n.................\n\nIf you are looking for information on a particular method of the Multiset class, have a look at the\n`API Documentation`_. It is automatically generated from the docstrings.\n\n.. _`API Documentation`: http://multiset.readthedocs.io/en/latest/api.html\n\nLicense\n-------\n\nLicensed under the MIT_ license.\n\n\n.. _multiset: https://en.wikipedia.org/wiki/Multiset\n.. _set: https://docs.python.org/3.10/library/stdtypes.html#set-types-set-frozenset\n.. _sets: set_\n.. _frozenset: set_\n.. _dict: https://docs.python.org/3.10/library/stdtypes.html#mapping-types-dict\n.. _`collections.Counter`: https://docs.python.org/3.10/library/collections.html#collections.Counter\n.. _MIT: https://opensource.org/licenses/MIT\n\n\n.. |pypi| image:: https://img.shields.io/pypi/v/multiset.svg?style=flat-square&label=latest%20stable%20version\n    :target: https://pypi.python.org/pypi/multiset\n    :alt: Latest version released on PyPi\n\n.. |coverage| image:: https://coveralls.io/repos/github/wheerd/multiset/badge.svg?branch=master\n    :target: https://coveralls.io/github/wheerd/multiset?branch=master\n    :alt: Test coverage\n\n.. |build| image:: https://github.com/wheerd/multiset/workflows/Tests/badge.svg?branch=master\n    :target: https://github.com/wheerd/multiset/actions?query=workflow%3ATests\n    :alt: Build status of the master branch\n\n.. |docs| image:: https://readthedocs.org/projects/multiset/badge/?version=latest\n    :target: http://multiset.readthedocs.io/en/latest/?badge=latest\n    :alt: Documentation Status\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "An implementation of a multiset.",
    "version": "3.1.0",
    "project_urls": {
        "Homepage": "https://github.com/wheerd/multiset"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cd17b6501f7dd171dadb16102f5d716b1997518010e47a2cc4cccd28b767d9c0",
                "md5": "db4289f1db1ef73893b571af5c3c35a0",
                "sha256": "2c6234e8196dbc319e65317f2c63d3df84a12ca920d20576b9c3bb924c76ec86"
            },
            "downloads": -1,
            "filename": "multiset-3.1.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "db4289f1db1ef73893b571af5c3c35a0",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.8",
            "size": 11141,
            "upload_time": "2024-04-05T20:48:58",
            "upload_time_iso_8601": "2024-04-05T20:48:58.675170Z",
            "url": "https://files.pythonhosted.org/packages/cd/17/b6501f7dd171dadb16102f5d716b1997518010e47a2cc4cccd28b767d9c0/multiset-3.1.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ff87e9b76cf3225549e6af95b32d0642d1a0364967e8393e66a62ed6244ec8e4",
                "md5": "2a5a4a490dbd2d9e61218b9b1b1d76e7",
                "sha256": "8e93e586f688d2e2b00fa5843e2a82f69e971e1ac7ad3d78f9d2a47608de9ba6"
            },
            "downloads": -1,
            "filename": "multiset-3.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "2a5a4a490dbd2d9e61218b9b1b1d76e7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 34241,
            "upload_time": "2024-04-05T20:49:00",
            "upload_time_iso_8601": "2024-04-05T20:49:00.241350Z",
            "url": "https://files.pythonhosted.org/packages/ff/87/e9b76cf3225549e6af95b32d0642d1a0364967e8393e66a62ed6244ec8e4/multiset-3.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-05 20:49:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "wheerd",
    "github_project": "multiset",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "tox": true,
    "lcname": "multiset"
}
        
Elapsed time: 0.32501s