Skip to main content

Stirling

CI

Installation

The stirling package is available on the Python Package Index (PyPI):

PyPI version

Stirling should work with Python 3.8 or greater. To install:

$ pip install stirling

Examples

A function for generating partitions of a collection into a specific number of non-empty subsets. The number of ways of arranging a set of size n into k non-empty subsets is known at the Stirling Number of the Second Kind or S(n, k).

For example, to find the arrangements of a list of 4 integers into 3 non-empty subsets, use:

>>> from stirling import k_subsets
>>> for arrangement in k_subsets([1, 2, 3, 4], 3):
...    print(arrangement)
...
[[1, 2], [3], [4]]
[[1, 3], [2], [4]]
[[1], [2, 3], [4]]
[[1, 4], [2], [3]]
[[1], [2, 4], [3]]
[[1], [2], [3, 4]]

To determine the number of arrangements of a set of 10 items into 5 non-empty subsets, use the s2 function:

>>> from stirling import s2
>>> s2(10, 5)
42525

MIT License

Copyright (c) Robert Smallshire

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Metadata

Release files for stirling 1.2.1

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

Source distribution (sdist)

Source distribution for stirling 1.2.1
File Size Uploaded
stirling-1.2.1.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for stirling 1.2.1
File Interpreter ABI Platform
stirling-1.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 10.5 kB

Release files / stirling-1.2.1.tar.gz

Download URL stirling-1.2.1.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e5936a78372a117ec1b7e3580716963dcfdff3b4dcaf89a691ab40e980ed0a3e
BLAKE2b-256 checksum
How to use checksums
b98436c921e774ca309202727d540297b91c9c6dbad520261a20c0fef61d64d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release files / stirling-1.2.1-py3-none-any.whl

Download URL stirling-1.2.1-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
368278cfe03d306f09b76105bf45c03a375b6867a064c0e8808fa306848e53a0
BLAKE2b-256 checksum
How to use checksums
a0af5748f12d6c113c48bd6179a2d19241bae34dc64e0ca22f4f243c5fc99415
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release history Release notifications | RSS feed

This release

1.2.1 This release

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.9.0

2 release files

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