Skip to main content

Apply a given function to all combinations of elements from multiple iterables

Project description

crosszip

PyPI Version License: MIT

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:

# 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:

# 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.

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

crosszip-1.0.0.tar.gz (346.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

crosszip-1.0.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file crosszip-1.0.0.tar.gz.

File metadata

  • Download URL: crosszip-1.0.0.tar.gz
  • Upload date:
  • Size: 346.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for crosszip-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b532f1ab18110d40ac1068d0cd71008cb6a514f121ef012417a0165b1b6d2473
MD5 309d1392ba7cfe477fcbea5999bae4ed
BLAKE2b-256 7e8ddd9a1309dca79e7ade628770fca557cf94959fd4d9d492edbba4a177e4e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for crosszip-1.0.0.tar.gz:

Publisher: release.yml on IndrajeetPatil/crosszip

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file crosszip-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: crosszip-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for crosszip-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cd863cf38d5935a61be7f8a4bb33fa24e2b6dc814abb2e670de8bb398db74dc8
MD5 c26fb8879cb48a75e4c4d47d99baf70e
BLAKE2b-256 d8da50d9e7156e33ade2859eb73b9d3b8427c53759eac130aebe02554af64595

See more details on using hashes here.

Provenance

The following attestation bundles were made for crosszip-1.0.0-py3-none-any.whl:

Publisher: release.yml on IndrajeetPatil/crosszip

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page