https://github.com/indrajeetpatil/crosszip
Iterating over all combinations from multiple iterables
https://github.com/indrajeetpatil/crosszip
pypi pypi-package python python-package utility
Last synced: 2 months ago
JSON representation
Iterating over all combinations from multiple iterables
- Host: GitHub
- URL: https://github.com/indrajeetpatil/crosszip
- Owner: IndrajeetPatil
- License: mit
- Created: 2024-11-19T20:29:49.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-17T09:59:08.000Z (about 1 year ago)
- Last Synced: 2025-04-18T00:36:28.311Z (about 1 year ago)
- Topics: pypi, pypi-package, python, python-package, utility
- Language: Python
- Homepage: https://indrajeetpatil.github.io/crosszip/
- Size: 1.25 MB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# crosszip 
[](https://pypi.org/project/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 add crosszip` |
## Usage
Example of using `crosszip`:
``` python
# @pyodide
# 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)
```
['cat_small_v1.0', 'cat_small_v2.0', 'cat_large_v1.0', 'cat_large_v2.0', 'dog_small_v1.0', 'dog_small_v2.0', 'dog_large_v1.0', 'dog_large_v2.0']
Example of using `pytest` marker `crosszip_parametrize`:
``` python
# @pyodide
# 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
print("Tests executed successfully.")
```
Tests executed successfully.
For more examples, check out the package documentation at:
## 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.
## Code of Conduct
Please note that the crosszip project is released with a [Contributor Code of Conduct](https://www.contributor-covenant.org/version/3/0/code_of_conduct/). By contributing to this project, you agree to abide by its terms.
## Acknowledgements
Hex sticker font is `Rubik`, and the image is taken from icon made by
Freepik and available at flaticon.com.