Registry / ai-ml / affinegap

affinegap

JSON →
library1.12pypypi✓ verified 84d ago

A Cython implementation of the affine gap string distance for measuring string similarity with affine gap penalties. Current version 1.12, stable but rarely updated.

pip install affinegap
INSTALL
IMPORT
SIG · AFFINEGAP
A
affinegap
ai-mlpythonv1.12
Install
1.6s avg
Import
Disk
18MB
Pass rate
4/ 10
Env Coverage4 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.12 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✓ —
✓ 1.5s
py 3.11
✕ build_error
✕ build_error
py 3.12
✕ build_error
✕ build_error
py 3.13
✕ build_error
✕ build_error
py 3.9
✓ —
✓ 1.7s
18MB installed
● package 18MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

affinegap
import affinegap
from affinegap import affinegap
affinegap is the module itself, not a function named affinegap; the main function is accessed as affinegap.affineGapDistance

Basic usage: compute affine gap string distance. The function returns an integer distance or similarity score depending on penalties.

import affinegap # Compute affine gap distance between two strings dist = affinegap.affineGapDistance("string1", "string2") print(dist) # With custom gap penalties dist = affinegap.affineGapDistance("hello", "hallo", match_weight=0, mismatch_weight=1, gap_weight=1, spatial_gap_weight=1) print(dist)
Debug
Known issues
gotchaThe function is named `affineGapDistance` (capital G) not `affinegap`. Many users mistakenly try `affinegap.distance()`.
fix
Use `affinegap.affineGapDistance(s1, s2)`
affects: all
gotchaDefault behavior: by default, match_weight=0, mismatch_weight=1, gap_weight=1, spatial_gap_weight=1. This means identical strings get distance 0, but a single mismatch or gap adds 1. This may not be what you expect for 'similarity'.
fix
Adjust parameters: e.g., match_weight=-1, mismatch_weight=1, gap_weight=-1 for similarity-like scores.
affects: all
gotchaAffine gap distance is not symmetric? Actually it is symmetric, but careful: the function expects two strings; if you pass integer or None, it may throw TypeError.
fix
Ensure both arguments are strings.
affects: all
Errors
Common errors & fixes
ImportError: cannot import name 'affinegap'
Trying to do `from affinegap import affinegap` instead of `import affinegap`.
fix
Replace with `import affinegap` and use `affinegap.affineGapDistance`.
AttributeError: module 'affinegap' has no attribute 'affinegap'
Same as above - the module does not contain a function named affinegap.
fix
Use `affinegap.affineGapDistance`.
TypeError: expected string or Unicode object
Passing a non-string (e.g., integer) to affineGapDistance.
fix
Convert arguments to strings: `affinegap.affineGapDistance(str(a), str(b))`
Upgrade
Version history
1.12latest on PyPI · released Jan 1, 2022
Audit
Dependencies

No dependency data recorded yet.

Agent activity
61 hits · last 30 days
node
51
OpenAI (training)
1
Resources
affinegap — pip install affinegap · libregistry