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, crosszip_parametrize Pytest plugin is a decorator that simplifies running tests with all possible combinations of parameter values.
This is particularly useful for testing functions or components across multiple dimensions of input parameters.
Installation
Install crosszip via pip:
pip install crosszip
Registering the crosszip marker for pytest is simple. Just add the following to your pytest.ini file:
[pytest]
markers =
crosszip_parametrize: "mark test function for crosszip parametrization"
Key Features
- Flexible Input: Works with any iterables, including lists, tuples, sets, and generators.
- pytest Plugin: Supports parametrization of tests using
crosszip. - Simple API: Minimalist, intuitive design for quick integration into your projects.
Usage
Example of using crosszip:
# 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)
# Output: ['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:
# Testing Power Function
import math
from crosszip_parametrize import crosszip_parametrize
@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/
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.
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-0.1.0.tar.gz.
File metadata
- Download URL: crosszip-0.1.0.tar.gz
- Upload date:
- Size: 307.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9867b967a3518b97c532428001f1e293b12851528aa90c9449b82b9413beb2c7
|
|
| MD5 |
7a2fd4ebd9419115d1b86b28a2ab2a50
|
|
| BLAKE2b-256 |
6f834d5c3dcbdc220fe3ab3f1563d38e998b82140d9f02c686c309fc6ab3f363
|
Provenance
The following attestation bundles were made for crosszip-0.1.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-0.1.0.tar.gz -
Subject digest:
9867b967a3518b97c532428001f1e293b12851528aa90c9449b82b9413beb2c7 - Sigstore transparency entry: 151105964
- Sigstore integration time:
-
Permalink:
IndrajeetPatil/crosszip@e97739a202abc0630ae4004016bb675a410940b1 -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/IndrajeetPatil
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e97739a202abc0630ae4004016bb675a410940b1 -
Trigger Event:
release
-
Statement type:
File details
Details for the file crosszip-0.1.0-py3-none-any.whl.
File metadata
- Download URL: crosszip-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d301fc2eb23cdf1fba88e4f6b95acba7cb927a3f8b3df1ed4eba5b2f2c96fca
|
|
| MD5 |
e0b9622c09bd75c6f147a2f673b3f639
|
|
| BLAKE2b-256 |
5f1d555151b6d8ab40624fd4e80d5bec85fde52023cfa00852c33492238c7510
|
Provenance
The following attestation bundles were made for crosszip-0.1.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-0.1.0-py3-none-any.whl -
Subject digest:
1d301fc2eb23cdf1fba88e4f6b95acba7cb927a3f8b3df1ed4eba5b2f2c96fca - Sigstore transparency entry: 151105965
- Sigstore integration time:
-
Permalink:
IndrajeetPatil/crosszip@e97739a202abc0630ae4004016bb675a410940b1 -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/IndrajeetPatil
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e97739a202abc0630ae4004016bb675a410940b1 -
Trigger Event:
release
-
Statement type: