semvec/pypi-packages huggingface dataset:
points2regions 0.0.6
A simple and efficient clustering tool for spatial 2D points with categorical labels.
License: MIT
Requires Python: >=3.8

# Points2Regions

Points2Regions is a Python tool designed for clustering and defining regions based on categorical marker data, commonly encountered in spatial biology. It provides methods for feature extraction, clustering, and generating various outputs like label masks, GeoJSON representations, and more.

## Installation

You can install Points2Regions using the following command:

```bash
pip install points2regions
```



## Usage

```python
from points2regions import Points2Regions
import pandas as pd

# Example usage with a CSV file
data = pd.read_csv('https://tissuumaps.dckube.scilifelab.se/private/Points2Regions/toy_data.csv')

# Create the clustering model
p2r = Points2Regions(
    data[['X', 'Y']], 
    data['Genes'], 
    pixel_width=1, 
    pixel_smoothing=5
)

# Cluster with a specified number of clusters
p2r.fit(num_clusters=15)

# Get cluster label for each marker
cluster_per_marker = p2r.predict(output='marker')

# Get a label mask
label_mask, tform = p2r.predict(output='pixel')

# Get connected components
connected_components, num_components, label_mask, tform  = p2r.predict(output='connected')
```

## Example
See the Jupyter Notebook `example.ipynb` for examples.

## License
This project is licensed under the MIT License. See the LICENSE file for details.
validdict 0.1.1
ValidDictorian: Declarative Python Dictionary Validator
License: MIT
Requires Python: <4.0,>=3.9

# ValidDictorian
### Declarative Python Dictionary Validator
Copyright 2024 Scott Perry, 
Available under the MIT license, 
GitHub repo: https://github.com/sperry04/validdict


## Purpose

`validdict` provides a way to declare schema validation rules for a Python dictionary using Python objects and types, rather than using a bespoke or interpreted schema validation language.  This allows validation of virtually any data that can be represented as a Python `dict`, such as input strings parsed by modules such as `pyyaml` or `json`.

Schemas are declarative with built-in scalar type validators, plus compositable map and sequence validators that allow the construction of complex schemas.


## Basic Usage

To use the `validdict` library, follow these steps:

1. Install the library by running the following command:
    ```
    pip install validdict
    ```

2. Import the `validdict` module in your Python script:
    ```python
    import validdict
    ```

3. Create a `Schema` instance with the declaration of a valid document. Each key in the document represents a field in the input dictionary, and the corresponding validation rules for allowed values. 

    For example:
    ```python
    from validdict import *

    schema = Schema({
        "int": Num(),
        "float": Num(),
        "bool": Bool(),
        "string": Str(),
        "regex": Regex(r"\w+@\w+\.com") # trivial email regex
    })
    ```

4. Use the schema to validate documents:

    ```python
    results = schema.validate({
        "int": 1,
        "float": 1.0,
        "string": "string",
        "bool": True,
        "regex": "example@email.com"
    })
    ```

5. Print, or otherwise process, the validation results:

    ```python
    print(results)
    ```

    Output:
    ```
    '<dict>' must be a map like: { RequiredKey(): Num(), RequiredKey(): Num(), RequiredKey(): <snip> = 'PASS'
        RequiredKey('int'):'int' must be type 'str' with value 'int' = 'PASS'
        int:'1' must be type in ('int', 'float') = 'PASS'
        RequiredKey('float'):'float' must be type 'str' with value 'float' = 'PASS'
        float:'1.0' must be type in ('int', 'float') = 'PASS'
        RequiredKey('string'):'string' must be type 'str' with value 'string' = 'PASS'
        string:'string' must be type 'str' = 'PASS'
        RequiredKey('bool'):'bool' must be type 'str' with value 'bool' = 'PASS'
        bool:'True' must be type 'bool' = 'PASS'
        RequiredKey('regex'):'regex' must be type 'str' with value 'regex' = 'PASS'
        regex:'example@email.com' must be type 'str' with value matching '\w+@\w+\.com' = 'PASS'
    ```

## Examples

1. [Validating literals](examples/1_literals.py)
2. [Handling validation results](examples/2_results.py)
3. [Validating scalar types](examples/3_scalars.py)
4. [Validating dictionary keys](examples/4_keys.py)
5. [Composition of large schemas](examples/5_composition.py)
6. [Advanced techniques](examples/6_advanced.py)