semvec/pypi-packages huggingface dataset:
queuepy 1.0.1
Simple module to create queues
License: MIT


##### PyQueue
##### A simple module lib to queue your lists!
**_Usage:_**
-
```py
# List: The list you are going to transform into a queue
# Length: The maximum size of the queue
# Input: The input from the user (can be a input('')) or an str

Queue(list, length, input)
# Returns the simple queue

Queue(list, length, input).input()
# Returns the element that was added

Queue(list, length, input).output()
# Returns the element that was removed

Queue(list, length, input).infos() # or .info()
# Returns the queue, the input and the output of the queue.
```

**_How it works_**
-
- Insert the wanted string onto the list if the maximum size of the list is less than the wanted size.
- If the size of the list is greater than the wanted size, pop out the last queue element and insert the wanted string.
---
### _TODO_:
- [ ] Add `.create()` function
	- will create 2 buffers for temporary usage.
	- e.g: `Queue(q, 3, in).create(1)`
		- creates a new buffer **inside** the **`Queue`** _class_ itself
		- can use `.input()`, `.output()` and `.infos()`
		- cannot be referenced outside the **`Queue`** _class_.
- [ ] Double-Reference `return` Methods
	- allows the user to reference `Queue` without needing to `print()` it. 
		- also allows the user to reference `Queue` with `print()`.
---
```mermaid
graph TD
    A[Read the input] -->|Verify if the size is less than the wanted|B(Insert string on the first position)
    B --> C{Check the queue}
    C -->|If the size is less|D[Insert at 0 and move the rest]
    C -->|If size is greater|E[Insert at 0 and pop the last]
    E --> F
    D --> F
    F{Rest of args}
    F --> |.input|H(print the new element)
    F --> |.output|G(print the removed element)
    F --> |info / infos|I(print the queue, the input and the output)
```
pyprotoclust 0.1.0
Hierarchical clustering using minimax linkage.
License: MIT
Requires Python: >=3.7,<4.0
Keywords: hierarchical,clustering,minimax,prototypes

.. image:: https://readthedocs.org/projects/pyprotoclust/badge/?version=latest
   :target: https://pyprotoclust.readthedocs.io/en/latest/?badge=latest
   :alt: Documentation Status

.. image:: https://img.shields.io/badge/License-MIT-blue.svg
   :target: https://lbesson.mit-license.org/
   :alt: MIT License

**Pyprotoclust** is an implementatin of representative hierarchical clustering using minimax linkage.

The original algorithm is from
`Hierarchical Clustering With Prototypes via Minimax Linkage <https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4527350/>`_
by Jacob Bien and Robert Tibshirani.

Pyprotoclust takes a distance matrix as input. It returns a linkage matrix encoding the hierachical clustering as well
as an additional list labelling the prototypes associated with each clustering. This allows a user to integrate with
the existing tools in the
`SciPy hierarchical clustering module <https://docs.scipy.org/doc/scipy/reference/cluster.hierarchy.html>`_.

Installation:

.. code-block:: python

    pip install pyprotoclust

Usage:

.. code-block:: python

    from pyprotoclust import protoclust
    import numpy as np
    import scipy as sp
    import scipy.cluster.hierarchy
    import scipy.spatial.distance

    # Generate two-dimensional toy data
    n = 60
    np.random.seed(4)
    params = [{'mean': [-7, 0], 'cov': [[1, 1], [1, 5]]},
              {'mean': [1, -1], 'cov': [[5, 0], [0, 1]]},
              {'mean': [3, 7], 'cov': [[1, 0], [0, 1]]}]
    data = np.vstack([np.random.multivariate_normal(p['mean'], p['cov'], n) for p in params])
    X = sp.spatial.distance.squareform(sp.spatial.distance.pdist(data))

    # Produce a hierarchical clustering using minimax linkage
    Z, prototypes = protoclust(X)

    # Generate clusters at a set cut_height using scipy's hierarchy module
    cut_height = 7
    T = sp.cluster.hierarchy.fcluster(Z, cut_height, criterion='distance')
    L,M = sp.cluster.hierarchy.leaders(Z, T)

    # Get the prototypes associated with the generated clusters
    P = data[prototypes[L]]


The previous example produces a linkage matrix Z and prototypes P that can be used to produce dendrograms and other
plots of the data.

.. figure:: docs/images/dendrogram.png
    :width: 400
    :align: center
    :alt: A dendrogram of the hierarchical clustering example.

    *A dendrogram of the hierarchical clustering example with a dashed line at the example cut height.*

.. figure:: docs/images/scatter.png
    :width: 400
    :align: center
    :alt: A scatter plot of the  hierarchical clustering example.

    *A scatter plot of the example with circles centered at prototypes drawn with radii equal to the top-level
    linkage heights of each cluster.*