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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sweetmatch-0.1.1.tar.gz (2.0 kB view details)

Uploaded Source

File details

Details for the file sweetmatch-0.1.1.tar.gz.

File metadata

  • Download URL: sweetmatch-0.1.1.tar.gz
  • Upload date:
  • Size: 2.0 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for sweetmatch-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2785e129c67dc6bf1e7cb10bf425b02ec56939aae40369082528908858b8340e
MD5 a9397919625de6d9c3accc6b605b79e6
BLAKE2b-256 3eea78ec668faf6ed59f4472dbdab87d0d7fa700d0aac1dfae6038b44e330f1d

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 file

0.1.0

1 file

Supported by

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