Apply a given function to all combinations of elements from multiple iterables
Project description
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:
# @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:
# @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: https://indrajeetpatil.github.io/crosszip/
Key Features
- Flexible Input: Works with any iterables, including lists, tuples, sets, and generators.
- pytest Plugin: Provides a
crosszip_parametrizemarker 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. 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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file crosszip-1.4.0.tar.gz.
File metadata
- Download URL: crosszip-1.4.0.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03c105778d241531acc8d1ac3aa59d0785d68375bd7070dddc7eb7c27e71c423
|
|
| MD5 |
23b5eac83f15a25b4fd8cbccc12b8df4
|
|
| BLAKE2b-256 |
d368e5b6121df73db971482f4c5523fd8f889d4fa55f5e0de0575114cc445e8a
|
Provenance
The following attestation bundles were made for crosszip-1.4.0.tar.gz:
Publisher:
release.yml on IndrajeetPatil/crosszip
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
crosszip-1.4.0.tar.gz -
Subject digest:
03c105778d241531acc8d1ac3aa59d0785d68375bd7070dddc7eb7c27e71c423 - Sigstore transparency entry: 1232211890
- Sigstore integration time:
-
Permalink:
IndrajeetPatil/crosszip@4db471afac9f8bab86e652aeb077322dc701d64e -
Branch / Tag:
refs/tags/v1.4.0 - Owner: https://github.com/IndrajeetPatil
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4db471afac9f8bab86e652aeb077322dc701d64e -
Trigger Event:
release
-
Statement type:
File details
Details for the file crosszip-1.4.0-py3-none-any.whl.
File metadata
- Download URL: crosszip-1.4.0-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0212f19e652241a74447c96368f27af13f056e1a8f0bb03b9cc5f9f07f3c64e7
|
|
| MD5 |
476448dd5cddd8db40da589434283d31
|
|
| BLAKE2b-256 |
33ccb6c829997f9f0f237018d44870b26da75b416585ca94feb09ed4aef23c4e
|
Provenance
The following attestation bundles were made for crosszip-1.4.0-py3-none-any.whl:
Publisher:
release.yml on IndrajeetPatil/crosszip
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
crosszip-1.4.0-py3-none-any.whl -
Subject digest:
0212f19e652241a74447c96368f27af13f056e1a8f0bb03b9cc5f9f07f3c64e7 - Sigstore transparency entry: 1232212015
- Sigstore integration time:
-
Permalink:
IndrajeetPatil/crosszip@4db471afac9f8bab86e652aeb077322dc701d64e -
Branch / Tag:
refs/tags/v1.4.0 - Owner: https://github.com/IndrajeetPatil
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4db471afac9f8bab86e652aeb077322dc701d64e -
Trigger Event:
release
-
Statement type: