partitionpi


Namepartitionpi JSON
Version 0.0.2 PyPI version JSON
download
home_pagehttps://github.com/luansimoes/partitionpi
SummaryPython library to handle integer partitions and compute partitional analysis metrics.
upload_time2024-04-13 21:38:27
maintainerNone
docs_urlNone
authorLuan Simões
requires_pythonNone
licenseMIT License
keywords integer-partition texture music partitional analysis
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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:

```Python
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:

```Python
# 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.

```Python
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.

```Python
# 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. 

```Python
# 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.](/img/example2.png)

Diagram for *p2*:

![Diagram from draw_complex.](/img/example.png)


## References
If you want to know more about Partitional Analysis, we refer to Pauxy Gentil-Nunes [webpage](https://pauxy.net/partitional-analysis-publications/) and [github](https://github.com/Pauxygnunes) page, where you can find publications, books and software about it.





            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/luansimoes/partitionpi",
    "name": "partitionpi",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "integer-partition texture music partitional analysis",
    "author": "Luan Sim\u00f5es",
    "author_email": "luansimoes@cos.ufrj.br",
    "download_url": "https://files.pythonhosted.org/packages/85/94/d4c92c8d7c0a65ca3cbaa1f905dad066d0b098bdbda7562f891209893c35/partitionpi-0.0.2.tar.gz",
    "platform": null,
    "description": "# Partition&pi;\r\nPartition&pi; is a Python library to handle integer partitions as lists and compute partitional analysis metrics. \r\n\r\n## Instalation\r\n```\r\npip install partitionpi\r\n```\r\n\r\n## Get started\r\nWe are dealing with integer partitions as lists, for example:\r\n\r\n```Python\r\nimport partitionpi as pp\r\n\r\np = [1,1,1,2,3]\r\n```\r\n\r\n### Computing main metrics\r\nWe 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:\r\n\r\n```Python\r\n# Compute the dispertion and agglomeration of p, that can be used for plotting.\r\nx = pp.disp(p)\r\ny = pp.agg(p)\r\n\r\n# Compute the number of children by each operation.\r\nnr_of_muted_children = pp.n_muted(p)\r\nnr_of_joint_children = pp.n_joint(p)\r\n\r\n# Translate p to both exponential and tex string form. \r\nexp = pp.exponential_form(p)\r\ntex = pp.as_tex_str(p)\r\n```\r\n\r\n### Operations\r\nAlso, 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.\r\n\r\n```Python\r\np1 = [1,1,2]\r\np2 = [1,2,3]\r\n\r\n# p1 + p2 = [1,1,1,2,2,3]\r\np_sum = pp.concat(p1, p2)\r\n\r\n# p1 - p2 = [1]\r\np_diff = pp.diff(p1, p2)\r\n\r\n# p1 intersection p2 = [1,2]\r\np_inter = pp.intersection(p1, p2)\r\n\r\n# p1 union p2 = [1,1,2,3]\r\np_union = pp.union(p1, p2)\r\n\r\n# join(p1, 1, 1) = [2,2,3]\r\np_join = pp.join(p1, 1, 1)\r\n\r\n# mute(p1, 3) = [1,1,2]\r\np_mute = pp.mute(p1, 3)\r\n```\r\n\r\n### Methods\r\nPartition&pi; gives some methods to enumerate objects, such as:\r\n\r\n- All partitions with a limited density-number.\r\n- All ancestors or children of a given partition.\r\n- The partitional complex of a given partition. \r\n\r\nAlso, we furnish methods to compute the common parents of two partitions and the list of possible referential partitions of a set of partitions.\r\n\r\n```Python\r\n# Compute the ancestors with density number at most 7\r\nancestors = pp.all_ancestors(p, max_dn=7)\r\n\r\n# Parents of p by each operation\r\nmparents = pp.muted_parents(p, max_dn=7)\r\njparents = pp.joint_parents(p)\r\n\r\n# Partitions with dn = 7 and with dn <= 7\r\np_eq_7 = partitions_of(7)\r\np_leq_7 = partitions_at_most(7)\r\n\r\n# Partitional complex of p\r\ncomp = pp.partitional_complex(p)\r\n\r\n# Common parents of p1 and p2\r\nparents = pp.common_parents(p1, p2)\r\n\r\n# List of possible referential partitions of [p, p1, p2]\r\nref = pp.referential_partition([p, p1, p2])\r\n```\r\n\r\n\r\n### Graph and Diagram\r\nFinally, 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. \r\n\r\n```Python\r\n# A nx.Graph modelling the partitional complex of g.\r\ng = graph_complex(p)\r\n\r\n# Plot diagram (can be called with the graph g or the partition p).\r\n# Mute edges will be painted red and Join edges will be painted black.\r\ndraw_complex(g, {'M' : 'red', 'J' : 'black'})\r\n```\r\nDiagram for *p*:\r\n\r\n![Diagram from draw_complex.](/img/example2.png)\r\n\r\nDiagram for *p2*:\r\n\r\n![Diagram from draw_complex.](/img/example.png)\r\n\r\n\r\n## References\r\nIf you want to know more about Partitional Analysis, we refer to Pauxy Gentil-Nunes [webpage](https://pauxy.net/partitional-analysis-publications/) and [github](https://github.com/Pauxygnunes) page, where you can find publications, books and software about it.\r\n\r\n\r\n\r\n\r\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Python library to handle integer partitions and compute partitional analysis metrics.",
    "version": "0.0.2",
    "project_urls": {
        "Homepage": "https://github.com/luansimoes/partitionpi"
    },
    "split_keywords": [
        "integer-partition",
        "texture",
        "music",
        "partitional",
        "analysis"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c650f8248766e49593c6650c25b44474270c2383707db73832d028d51da9fc83",
                "md5": "b507f78ba25ff7d339dae30f20e8bab8",
                "sha256": "8d0e1c9a8929bcd2cc6cd5538602b11d0df91651009c3518154d7294f1807b34"
            },
            "downloads": -1,
            "filename": "partitionpi-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b507f78ba25ff7d339dae30f20e8bab8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 8003,
            "upload_time": "2024-04-13T21:38:25",
            "upload_time_iso_8601": "2024-04-13T21:38:25.514553Z",
            "url": "https://files.pythonhosted.org/packages/c6/50/f8248766e49593c6650c25b44474270c2383707db73832d028d51da9fc83/partitionpi-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8594d4c92c8d7c0a65ca3cbaa1f905dad066d0b098bdbda7562f891209893c35",
                "md5": "321cabc35d24a84941abb7fd792ff9a5",
                "sha256": "e514c876de0b8c4b8f7aa68b8c7947ad58a009fd46ce26b01ac1c8d4ef93cec7"
            },
            "downloads": -1,
            "filename": "partitionpi-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "321cabc35d24a84941abb7fd792ff9a5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 7637,
            "upload_time": "2024-04-13T21:38:27",
            "upload_time_iso_8601": "2024-04-13T21:38:27.529775Z",
            "url": "https://files.pythonhosted.org/packages/85/94/d4c92c8d7c0a65ca3cbaa1f905dad066d0b098bdbda7562f891209893c35/partitionpi-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-13 21:38:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "luansimoes",
    "github_project": "partitionpi",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "partitionpi"
}
        
Elapsed time: 0.53981s