-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.qmd
83 lines (56 loc) · 2.38 KB
/
README.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
---
format: gfm
execute:
eval: true
---
# crosszip <img src="https://raw.githubusercontent.com/IndrajeetPatil/crosszip/main/docs/assets/logo.png" align="right" width="240" />
[![PyPI version](https://img.shields.io/pypi/v/crosszip)](https://pypi.org/project/crosszip/)
![Python versions](https://img.shields.io/pypi/pyversions/crosszip)
[![PyPI Downloads](https://img.shields.io/pypi/dm/crosszip)](https://pypistats.org/packages/crosszip)
`crosszip` is a Python utility that makes it easy to apply a function to all possible combinations of elements from multiple iterables.
It combines the power of the Cartesian product and functional programming into a single, intuitive tool.
Additionally, `@pytest.mark.crosszip_parametrize` is a `pytest` marker that simplifies running tests with all possible combinations of parameter values.
## Installation
| Package Manager | Installation Command |
| --------------- | ------------------------- |
| pip | `pip install crosszip` |
| uv | `uv pip install crosszip` |
## Usage
Example of using `crosszip`:
```{python}
# Label Generation for Machine Learning
from crosszip import crosszip
def create_label(category, subcategory, version):
return f"{category}_{subcategory}_v{version}"
categories = ["cat", "dog"]
subcategories = ["small", "large"]
versions = ["1.0", "2.0"]
labels = crosszip(create_label, categories, subcategories, versions)
print(labels)
```
Example of using `pytest` marker `crosszip_parametrize`:
```{python}
# Testing Power Function
import math
import crosszip
import pytest
@pytest.mark.crosszip_parametrize(
"base",
[2, 10],
"exponent",
[-1, 0, 1],
)
def test_power_function(base, exponent):
result = math.pow(base, exponent)
assert result == base**exponent
```
For more examples, check out the package documentation at:
<https://indrajeetpatil.github.io/crosszip/>
## Key Features
- **Flexible Input**: Works with any iterables, including lists, tuples, sets, and generators.
- **pytest Plugin**: Provides a `crosszip_parametrize` marker for running tests with all possible combinations of parameter values.
- **Simple API**: Minimalist, intuitive design for quick integration into your projects.
## License
This project is licensed under the MIT License.
## Acknowledgements
Hex sticker font is `Rubik`, and the image is taken from icon made by Freepik and available at flaticon.com.