Skip to main content

madge

Last version Build Status Python Version Coverage Downloads

partition

```partiton` is a Python algorithm library which provides efficient algorithms for the number partition problem. You can also use it from shell command. These algorithms have many applications. One typical one is for parallel software testing. Currently, the following three algorithms are supported:

  • greedy algorithm, which is a benchmark algorithm with simple login
  • differencing algorithm, a.k.a. Karmarkar–Karp(KK) algorithm
  • dynamic programming(DP) algorithm, which is optimal for scenarios where the size of integers is not too large

Install

Use pip:

pip install partition

From source code:

python setup.py develop

How to use

command line usage

Get help:

partition -h

Query version:

partition --version

Available options:

usage: partition [-h] [--numbers NUMBERS] [--grouplen GROUPLEN]
                 [--algorithm {greedy,kk,dp}] [--version]

optional arguments:
  -h, --help            show this help message and exit
  --numbers NUMBERS     integer numbers to be partitioned, seperated by comma
  --grouplen GROUPLEN   length of groups to hold the partitioned integer
                        numbers, default is 2
  --algorithm {greedy,kk,dp}
                        select partition algorithms, available options are
                        greedy, kk and dp
  --version             print version

For example:

root@foo:~# partition --numbers 1,2,3,4,5 --grouplen 2 --algorithm greedy
Partition 1,2,3,4,5 into 2 groups, using algorithm: greedy
Group: 0, numbers: [5, 2, 1]
Group: 1, numbers: [4, 3]
Min group sum: 7, Max group sum: 8, difference: 1
Group(s) with min sum: [4, 3]
Group(s) with max sum: [5, 2, 1]
([[5, 2, 1], [4, 3]], 1)

python library usage

In [1]: import partition

In [2]: partition.partition.__version__
Out[2]: '0.1.0'

In [3]: partition.greedy.greedy([1,2,3,4,5], 2)
Out[3]: [[5, 2, 1], [4, 3]]

In [4]: partition.kk.kk([1,2,3,4,5], 2)
Out[5]: [[5, 3], [1, 2, 4]]

Lisense

MIT

Maintenance

This tool is developed by slxiao. You are welcome to raise any issues about the tool.

Metadata

Release files for partition 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for partition 0.1.2
File Size Uploaded Provenance Actions
partition-0.1.2.tar.gz 4.3 kB Without provenance Details for partition-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for partition 0.1.2
File Interpreter ABI Platform Actions
partition-0.1.2-py2-none-any.whl Python 2 none any Details for partition-0.1.2-py2-none-any.whl

Total release size: 9.6 kB

Release files / partition-0.1.2.tar.gz

Download URL partition-0.1.2.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f2597c83ce7f2116a5bed92b9c6f9216d70c41bdf8d8b8cab24fcb9e5f287d5c
BLAKE2b-256 checksum
How to use checksums
483f576f9c059c4d54d581d957bd00f52c550958b9b0bfae8535c02b8a6376ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.4.2 requests/2.11.1 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/2.7.12

Release files / partition-0.1.2-py2-none-any.whl

Download URL partition-0.1.2-py2-none-any.whl
Size 5.4 kB
Tags Python 2
SHA-256 checksum
How to use checksums
75c60b2158bb58c6018a4246af1fcb287a9c2eba9133eb2730ea7361021af31f
BLAKE2b-256 checksum
How to use checksums
42f0366b5b2c3d57484568cc2373cd1621e2e26de215ddcdb855854fad909eb2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.4.2 requests/2.11.1 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/2.7.12

Security for partition 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page