Skip to main content

Python library to handle integer partitions and compute partitional analysis metrics.

Project description

Partitionπ

Partitionπ is a Python library to handle integer partitions as lists and compute partitional analysis metrics.

Instalation

pip install partitionpi

Get started

We are dealing with integer partitions as lists, for example:

import partitionpi as pp

p = [1,1,1,2,3]

Computing main metrics

We provide methods to compute the main metrics related to partitional_analysis, such as the indices of agglomeration and dispersion, number of children obtained by the operations of mute and join, translation between the list form and the exponential form (via tuple or latex string)... Examples of usage of such functions:

# Compute the dispertion and agglomeration of p, that can be used for plotting.
x = pp.disp(p)
y = pp.agg(p)

# Compute the number of children by each operation.
nr_of_muted_children = pp.n_muted(p)
nr_of_joint_children = pp.n_joint(p)

# Translate p to both exponential and tex string form. 
exp = pp.exponential_form(p)
tex = pp.as_tex_str(p)

Operations

Also, our library furnishes operations between partitions, such as union, intersection, concatenation/sum, difference and the operators mute and join. Union, intersection, sum and difference are computed like the multiset operators.

p1 = [1,1,2]
p2 = [1,2,3]

# p1 + p2 = [1,1,1,2,2,3]
p_sum = pp.concat(p1, p2)

# p1 - p2 = [1]
p_diff = pp.diff(p1, p2)

# p1 intersection p2 = [1,2]
p_inter = pp.intersection(p1, p2)

# p1 union p2 = [1,1,2,3]
p_union = pp.union(p1, p2)

# join(p1, 1, 1) = [2,2,3]
p_join = pp.join(p1, 1, 1)

# mute(p1, 3) = [1,1,2]
p_mute = pp.mute(p1, 3)

Methods

Partitionπ gives some methods to enumerate objects, such as:

  • All partitions with a limited density-number.
  • All ancestors or children of a given partition.
  • The partitional complex of a given partition.

Also, we furnish methods to compute the common parents of two partitions and the list of possible referential partitions of a set of partitions.

# Compute the ancestors with density number at most 7
ancestors = pp.all_ancestors(p, max_dn=7)

# Parents of p by each operation
mparents = pp.muted_parents(p, max_dn=7)
jparents = pp.joint_parents(p)

# Partitions with dn = 7 and with dn <= 7
p_eq_7 = partitions_of(7)
p_leq_7 = partitions_at_most(7)

# Partitional complex of p
comp = pp.partitional_complex(p)

# Common parents of p1 and p2
parents = pp.common_parents(p1, p2)

# List of possible referential partitions of [p, p1, p2]
ref = pp.referential_partition([p, p1, p2])

Graph and Diagram

Finally, we furnish tools for generating a networkx graph of the partitional complex with labelled nodes and edges, and to plot its diagram. In the graph, each node has an attribute pos, which gives the pair (agg, disp) of each partition, and an attribute label, with the tex-style form of the partition. Each edge has the attribute kinship, that tells if it represents a mute (M) or a join (J) relation.

# A nx.Graph modelling the partitional complex of g.
g = graph_complex(p)

# Plot diagram (can be called with the graph g or the partition p).
# Mute edges will be painted red and Join edges will be painted black.
draw_complex(g, {'M' : 'red', 'J' : 'black'})

Diagram for p:

Diagram from draw_complex.

Diagram for p2:

Diagram from draw_complex.

References

If you want to know more about Partitional Analysis, we refer to Pauxy Gentil-Nunes webpage and github page, where you can find publications, books and software about it.

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

partitionpi-0.0.2.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

partitionpi-0.0.2-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file partitionpi-0.0.2.tar.gz.

File metadata

  • Download URL: partitionpi-0.0.2.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.2

File hashes

Hashes for partitionpi-0.0.2.tar.gz
Algorithm Hash digest
SHA256 e514c876de0b8c4b8f7aa68b8c7947ad58a009fd46ce26b01ac1c8d4ef93cec7
MD5 321cabc35d24a84941abb7fd792ff9a5
BLAKE2b-256 8594d4c92c8d7c0a65ca3cbaa1f905dad066d0b098bdbda7562f891209893c35

See more details on using hashes here.

File details

Details for the file partitionpi-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: partitionpi-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.2

File hashes

Hashes for partitionpi-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8d0e1c9a8929bcd2cc6cd5538602b11d0df91651009c3518154d7294f1807b34
MD5 b507f78ba25ff7d339dae30f20e8bab8
BLAKE2b-256 c650f8248766e49593c6650c25b44474270c2383707db73832d028d51da9fc83

See more details on using hashes here.

Supported by

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