Metadata-Version: 2.4
Name: unik
Version: 1.0
Summary: Provide functionality for working with selections of unique items in lists / arrays
Author-email: Gabriel Brammer <gbrammer@gmail.com>
License: MIT License
        
        Copyright (c) 2025 Gabe Brammer
        
        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.
        
Project-URL: Homepage, https://github.com/gbrammer/unik
Project-URL: Repository, https://github.com/gbrammer/unik
Project-URL: Issues, https://github.com/gbrammer/unik/issues
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Provides-Extra: test
Requires-Dist: pytest>=7.0; extra == "test"
Requires-Dist: build>=0.10.0; extra == "test"
Requires-Dist: twine>=4.0.0; extra == "test"
Requires-Dist: flake8; extra == "test"
Dynamic: license-file

# unik

Provide functionality for working with selections of unique items in lists / arrays

## Installation

You can install unik using pip:

```bash
pip install unik
```

## Usage

```python
>>> import numpy as np
>>> from unik import Unique

>>> items = [1, 2, 2, 2, 3, 1, 4, 3]
>>> un = Unique(items, verbose=True)
   N  value     
====  ==========
   2           1
   3           2
   2           3
   1           4
  
>>> print(un.info(sort_counts=True))
   N  value     
====  ==========
   1           4
   2           1
   2           3
   3           2

>>> items = np.array(['apples', 'apples', 'oranges', 'apples', 'grapes'])
>>> un = Unique(items, verbose=True)
   N  value     
====  ==========
   3  apples    
   1  grapes    
   1  oranges   

>>> print(np.array(un.values)[un.counts > 1])
['apples']

>>> another_array = np.array(['tree', 'tree', 'tree', 'tree', 'vine'])
>>> for i in un.unique_index():
>>>     print(f'{items[i]} grow on a {another_array[i]}')
apples grow on a tree
grapes grow on a vine
oranges grow on a tree

# __get__ builtin returns boolean array
>>> print(un['apples'])
[ True  True False  True False]

>>> print(items[~un['apples']])
['oranges' 'grapes']

>>> print(another_array[~un['apples']])
['tree' 'vine']

```

## License

MIT License - see LICENSE file for details
