Skip to main content

An implementation of a multiset.

Project description

This package provides a multiset implementation for python.

Latest version released on PyPi Test coverage Build status of the master branch Documentation Status

Overview

A multiset is similar to the builtin set, but it allows an element to occur multiple times. It is an unordered collection of element 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

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.

There is currently no immutable version of the multiset, because there is no immutable version of dict.

Installation

Installing multiset is simple with pip:

$ pip install multiset

Documentation

The documentation is available at Read the Docs.

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.

License

Licensed under the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

multiset-0.2.tar.gz (28.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

multiset-0.2-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file multiset-0.2.tar.gz.

File metadata

  • Download URL: multiset-0.2.tar.gz
  • Upload date:
  • Size: 28.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for multiset-0.2.tar.gz
Algorithm Hash digest
SHA256 a7c21481ffda084544549d334a4ac02af485c94d72617305332588456d179677
MD5 1ac56d0f1811e84bc7d23d9e6905891f
BLAKE2b-256 a528bd4b8295178822dc7f14a1936b3f1baf6e7ef98be72b52fc37e4577292a2

See more details on using hashes here.

File details

Details for the file multiset-0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for multiset-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cb83e18eef6db13a9f52ef739c458eee63fbacea09c2e3ef131b0290eb6d51b3
MD5 772e737734b629db3a6ca2a58f7adc43
BLAKE2b-256 b45a84ef25475325a616635137dd3a44d534c319637e005b1dd06cbfd2f13152

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page