Skip to main content

Fast ellipse tangency solver

Project description

EllPHi – a fast ellipse-tangency solver for anisotropic persistent homology

CI codecov ellphi-logo

EllPHi brings anisotropy to persistent-homology workflows.

Starting from an ordinary point cloud, it estimates local covariance, inflates ellipsoids instead of balls, and feeds the resulting tangency distance into your favourite PH backend (HomCloud, Ripser, and so on). The result: cleaner barcodes, longer lifetimes, and ring structures that survive heavy noise — all without rewriting your topology code.

Features

  • Ellipse Creation: Easily create ellipses from covariance matrices or directly from point cloud neighborhoods.
  • Tangency Distance: Compute the tangency distance between pairs of ellipses, a key component for anisotropic persistent homology.
  • High-Performance Backend: Includes a C++ backend for fast and efficient tangency calculations, with a pure Python fallback for portability.
  • N-Dimensional Support: Works with n-dimensional ellipsoids, allowing for analysis in higher-dimensional spaces.
  • Visualization: Comes with helper functions to quickly visualize ellipse clouds using Matplotlib.

Installation

Install from PyPI:

pip install ellphi

To install with demo dependencies for notebooks and examples:

pip install ellphi[demo]

Supported Python Versions

Python 3.10 or later.

Quick start

Install and solve a tangency query in just a few lines:

pip install ellphi
import numpy as np
import ellphi

pcoef = ellphi.coef_from_cov([0.0, 0.0], [[0.2, 0.0], [0.0, 0.1]])[0]
qcoef = ellphi.coef_from_cov([1.0, 0.25], [[0.15, 0.0], [0.0, 0.25]])[0]

result = ellphi.tangency(pcoef, qcoef)
print(f"t = {result.t:.3f}")       # tangency distance
print(f"point = {result.point}")

Usage

Here's a complete example of how to create an ellipse cloud from a point cloud and compute the pairwise tangency distances:

import numpy as np
import ellphi

# 1. Generate a sample point cloud
np.random.seed(42)
X = np.random.rand(100, 2)

# 2. Create an ellipse cloud from the point cloud
# This will estimate the local covariance for each point's neighborhood
ellipses = ellphi.ellipse_cloud(X, k=5)

# 3. Compute the pairwise tangency distances
# This will use the C++ backend if available
distances = ellipses.pdist_tangency()

print("Computed tangency distances for", len(distances), "pairs of ellipses.")

For deeper workflows, see the accompanying notebooks:

Check the installed version

Inside Python:

import ellphi

print(ellphi.version_info())

From the shell:

python -m ellphi --version

Contributing

Interested in contributing? We welcome pull requests!

To get started with development, clone the repository and set up your environment:

git clone https://github.com/t-uda/ellphi.git
cd ellphi

# Install dependencies, including development tools
poetry install --with dev

# Run the tests to make sure everything is set up correctly
poetry run pytest

Project details


Download files

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

Source Distribution

ellphi-0.1.1.post1.tar.gz (34.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ellphi-0.1.1.post1-cp312-cp312-macosx_14_0_arm64.whl (58.5 kB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

File details

Details for the file ellphi-0.1.1.post1.tar.gz.

File metadata

  • Download URL: ellphi-0.1.1.post1.tar.gz
  • Upload date:
  • Size: 34.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.13.3 Darwin/23.6.0

File hashes

Hashes for ellphi-0.1.1.post1.tar.gz
Algorithm Hash digest
SHA256 80fffeecf306fd871071dceda0256d1e332300fb3891eee6e662908cf164be40
MD5 374e93a2d35a9021704ad54759880031
BLAKE2b-256 d53bd26272fce9a18fc7d58cf8f0f9c7ae69f02ba8327ef45277e8fd863135fb

See more details on using hashes here.

File details

Details for the file ellphi-0.1.1.post1-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for ellphi-0.1.1.post1-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 9c586813305d15508323515f8e1aed536a9c7d755e46ec3277e8c82d860db40d
MD5 ec7dcba62767758d091d1d8b16e1cb32
BLAKE2b-256 90ab442e2eb8707da4156190a63bc5eba5cabbc584d19da7a023272606a58b13

See more details on using hashes here.

Supported by

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