semvec/pypi-packages huggingface dataset:
stirling 1.2.1
Set partitioning
License: MIT License
Keywords: sets partitioning

# Stirling

![CI](https://github.com/rob-smallshire/stirling/actions/workflows/actions.yml/badge.svg)


## Installation

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

[![PyPI version](https://badge.fury.io/py/stirling.svg)](https://badge.fury.io/py/stirling)

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](https://en.wikipedia.org/wiki/Stirling_numbers_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.