Registry / data / similaritymeasures

similaritymeasures

JSON →
library1.4.0pypypi✓ verified 84d ago

Python library for quantifying the difference between two arbitrary curves in space. Provides implementations of common similarity measures including discrete Fréchet distance, dynamic time warping, curve length measure, area between two curves, and more. Current version 1.4.0, supports Python >=3.8, released under MIT license.

pip install similaritymeasures
INSTALL
IMPORT
SIG · SIMILARITYMEASURES
S
similaritymeasures
datapythonv1.4.0
Install
7.4s avg
Import
1306ms
Disk
229MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.4.0 · 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
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 1.318s · 230.7MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 7.4s · import 1.294s · 222MB
229MB installed
● package 229MB
Code
Verified usage

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

similaritymeasures
import similaritymeasures
Import the module itself; functions are accessed as similaritymeasures.frechet_dist(...)
Frechet distance function
similaritymeasures.frechet_dist
frechet_dist
frechet_dist is not a top-level import; must be accessed via the module

Demonstrates basic usage of main similarity measures

import numpy as np import similaritymeasures # Define two curves as arrays of (x, y) points p = np.array([[1, 1], [2, 1], [3, 2]]) q = np.array([[1, 1], [2, 3], [3, 2]]) # Discrete Frechet distance frechet = similaritymeasures.frechet_dist(p, q) print(f"Frechet distance: {frechet}") # Dynamic time warping (DTW) dtw, d = similaritymeasures.dtw(p, q) print(f"DTW distance: {dtw}") # Area between two curves area = similaritymeasures.area_between_two_curves(p, q) print(f"Area between curves: {area}") # Curve length measure clm = similaritymeasures.curve_length_measure(p, q) print(f"Curve length measure: {clm}")
Debug
Known issues
breakingIn version 1.0.0, `area_between_two_curves` changed behavior for degenerate cases (e.g., repeating points or collinear points). The area may now differ from previous versions.
fix
Review area values if upgrading from <1.0.0; the new behavior is correct per the mathematical definition.
affects: >=1.0.0
breakingIn version 0.6.0, `similaritymeasures.pcm` changed outputs. To get previous behavior, set `norm_seg_length=True`.
fix
If you need the old PCM results, call `similaritymeasures.pcm(p, q, norm_seg_length=True)`.
affects: >=0.6.0
gotchaThe functions expect inputs as 2D numpy arrays of shape (n, 2) for 2D curves. Passing lists or arrays of different shapes may cause errors or incorrect results.
fix
Ensure both curves are numpy arrays with shape (n, 2) or (n, 3) for 3D.
affects: all
Errors
Common errors & fixes
ImportError: cannot import name 'frechet_dist' from 'similaritymeasures'
Attempting to import the function directly instead of the module.
fix
Use `import similaritymeasures` then `similaritymeasures.frechet_dist(...)`.
ValueError: operands could not be broadcast together with shapes
Input curves have different number of points and not compatible for element-wise operations (e.g., `area_between_two_curves` requires equal lengths).
fix
Ensure both curves have the same number of points, or use DTW which can handle different lengths.
TypeError: only size-1 arrays can be converted to Python scalars
Passing a list or tuple that isn't converted to numpy array, or ragged arrays.
fix
Convert your curves to numpy arrays: `p = np.array(p)` and `q = np.array(q)`.
Upgrade
Version history
1.4.0latest on PyPI · released Oct 18, 2025
Audit
Dependencies
numpyrequiredRequired for all numerical operations
scipyrequiredRequired for Frechet distance (scipy.spatial.distance.cdist) and DTW
Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources
similaritymeasures — pip install similaritymeasures · libregistry