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.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-cp312-cp312-macosx_14_0_arm64.whl (58.4 kB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

File details

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

File metadata

  • Download URL: ellphi-0.1.1.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.tar.gz
Algorithm Hash digest
SHA256 e2ed5dff1ae3cabf2bab2565ee8b5bed9fdb153d83e2b0f5bbe516ea9e952cb7
MD5 25c8064062047a4e852ed366369a6503
BLAKE2b-256 7f393f2cd1f1c6d4d0e8249e056bce2bf855bf0c1a81cc01919af93cad9417d0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ellphi-0.1.1-cp312-cp312-macosx_14_0_arm64.whl
  • Upload date:
  • Size: 58.4 kB
  • Tags: CPython 3.12, macOS 14.0+ ARM64
  • 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-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 5ae0187ff29a5e35caeb89f7b910fe63a48b0cedc3dc6a41ceaa89d05565909e
MD5 0def1e6284fb503c2203b4232177f205
BLAKE2b-256 a3a6cd493941fffb2b0dba9af9a97ef4e45a4aa522b52515235c2ea452b59129

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