Skip to main content

cyminiball

image License Build Status Coverage Status CodeFactor DeepSource

A Python package to compute the smallest bounding ball of a point cloud in arbitrary dimensions. A Python/Cython binding of the popular miniball utility by Bernd Gärtner.

To my knowledge, this is currently the fastest implementation available in Python. For other implementations see:

Installation:

The package is available via pip.

python -m pip install cyminiball

Usage:

import cyminiball as miniball
import numpy as np

d = 2               # Number of dimensions
n = 10000           # Number of points
dt = np.float64     # Data type

points = np.random.randn(n, d)
points = points.astype(dt)
C, r2 = miniball.compute(points)
print("Center:", C)
print("Radius:", np.sqrt(r2))

Additional output can be generated using the details flag and compute_max_chord().

C, r2, info = miniball.compute(points, details=True)
# Returns an info dict with the following keys:
#       center:         center
#       radius:         radius
#       support:        indices of the support points
#       relative_error: error measure realtive to r2
#       is_valid:       numerical validity
#       elapsed:        time required
#
# The maximal chord is the longest line connecting any
# two of the support points. The following extends the
# info dict by the following keys:
#       pts_max:        point coordinates of the two points
#       ids_max:        ids of the two extreme points
#       d_max:          length of the maximal chord
(p1, p2), d_max = miniball.compute_max_chord(points, info=info)

See examples/examples.py for further usage examples

Build package

Building the package requires

  • Python 3.x
  • Cython
  • numpy

First, download the project and set up the environment.

git clone "https://github.com/hirsch-lab/cyminiball.git"
cd cyminiball
python -m pip install -r "requirements.txt"

Then build and install the package. Run the tests/examples to verify the package.

./build_install.sh
python "tests/test_all.py"
python "examples/examples.py"

Performance

For a comparison with miniballcpp, run the below command. In my experiments, the Cython-optimized code ran 10-50 times faster, depending on the number of points and point dimensions.

python "examples/comparison.py"

Metadata

Release files for cyminiball 2.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cyminiball 2.1.2
File Size Uploaded
cyminiball-2.1.2.tar.gz 185.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cyminiball 2.1.2
File Interpreter ABI Platform
cyminiball-2.1.2-cp310-cp310-macosx_15_0_arm64.whl CPython 3.10 CPython 3.10 macOS 15.0+ ARM64 Details

Total release size: 314.8 kB

Release files / cyminiball-2.1.2.tar.gz

Download URL cyminiball-2.1.2.tar.gz
Size 185.9 kB
Tags Source
SHA-256 checksum
How to use checksums
429c254a4c5054979bf32f8d9aa1ead48122354d9d6af75638d588796c2e1661
BLAKE2b-256 checksum
How to use checksums
c51c9d1c1f305597d6dc8dde9ed1660c0bc019ec4b0a63e8a80a9f280b4b929c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.5

Release files / cyminiball-2.1.2-cp310-cp310-macosx_15_0_arm64.whl

Download URL cyminiball-2.1.2-cp310-cp310-macosx_15_0_arm64.whl
Size 128.9 kB
Tags CPython 3.10 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
1409bb98a1a4f2383869417226166093107afb51f4724fd6f5f373123e1830dd
BLAKE2b-256 checksum
How to use checksums
bf997ff6cd153cc9b5cc5deaa6e3a9bfca300b7964b0b072076958a1ff3a43e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.5

Release history Release notifications | RSS feed

This release

2.1.2 This release

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page