$ show wmayner/pyemd
PyEMD is a pure Python library for computing the Earth Mover's Distance (also known as Wasserstein distance) between histograms. As of version 2.0, it serves as a thin wrapper around the POT (Python Optimal Transport) library, providing three main functions: `emd()` for computing the EMD value, `emd_with_flow()` for getting both the EMD value and the flow matrix, and `emd_samples()` for computing EMD directly from sample arrays. The library implements optimizations from the original C++ implementation, including pre-flow cancellation of mass within same bins for zero-cost transport. It follows modern Python packaging practices with pyproject.toml, uses setuptools_scm for version management, and maintains comprehensive test coverage.
The LLM identified 1 files worth highlighting for reuse:
Contains the core EMD implementation with pre-flow optimization that cancels mass within same bins (zero-cost transport) before computing actual transport. Implements proper validation, handles edge cases, and uses POT's partial_wasserstein for the core computation. Demonstrates domain-specific knowledge of the EMD algorithm and provides a clean, reusable implementation that could be extracted with minimal changes.