Skip to main content

sweetmatch

This is sugar coating around the function scipy.optimize.linear_sum_assignment (Hungarian algo). The single provided function is sweetmatch.match, which takes 2 lists of any objects, a callable that evaluates how bad 2 objects match together (cost function) and an optional threshold value. The match function returns a list of matched pairs. Typing is correctly handled. In action:

from sweetmatch import match

x = [1, 2, 3]
y = [1.6, 2.1, 3.2]

def cost_function(x:int, y:float) -> float:
    return abs(x - y)

matches = match(x, y, cost_function)

print(matches)

# [(1, 1.6), (2, 2.1), (3, 3.2)]


matches = match(x, y, cost_function, cost_threshold=0.5)

print(matches)

# [(2, 2.1), (3, 3.2)]

In this example, the typing of the outputed matches is correctly handled and is list[tuple[int, float]].

Installation

pip install sweetmatch

Metadata

Release files for sweetmatch 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sweetmatch 0.1.1
File Size Uploaded
sweetmatch-0.1.1.tar.gz 2.0 kB Details

Release files / sweetmatch-0.1.1.tar.gz

Download URL sweetmatch-0.1.1.tar.gz
Size 2.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2785e129c67dc6bf1e7cb10bf425b02ec56939aae40369082528908858b8340e
BLAKE2b-256 checksum
How to use checksums
3eea78ec668faf6ed59f4472dbdab87d0d7fa700d0aac1dfae6038b44e330f1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.7.0 requests/2.25.1 setuptools/64.0.3 requests-toolbelt/0.9.1 tqdm/4.66.1 CPython/3.8.16

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page