Python interface for DualPerspective.jl - A Julia package for solving large-scale KL divergence problems
Project description
DualPerspective Python Package
Python interface for DualPerspective.jl, a Julia package for solving large-scale KL divergence problems.
Installation
pip install DualPerspective
The package will automatically:
- Install Julia if not already installed (via juliacall)
- Install the DualPerspective.jl Julia package
- Perform precompilation to ensure fast performance from the first run
Usage
import numpy as np
from DualPerspective import DPModel, solve, regularize
# Generate sample data
np.random.seed(42)
n = 200 # dimension of solution
m = 100 # number of measurements
x0 = np.random.rand(n)
x0 = np.pi * x0 / np.sum(x0) # Rescale to sum to pi
A = np.random.rand(m, n)
b = A @ x0
# Create and solve the problem
model = DPModel(A, b)
regularize(model, 1e-4) # Optional: set regularization parameter
solution = solve(model)
print(f"Sum of solution: {np.sum(solution):.6f} (should be ≈ {np.pi:.6f})")
print(f"Optimal solution shape: {solution.shape}")
Reinstalling the DualPerspective.jl package
To reinstall or update the DualPerspective.jl package, you can use the following command:
pip install --force-reinstall DualPerspective
Performance Considerations
This Python interface uses Julia's precompilation features to ensure good performance from the first run. The first import of the package may take slightly longer as it sets up the Julia environment, but subsequent operations should be fast.
Features
- Easy-to-use Python interface for DualPerspective.jl
- Automatic installation of Julia dependencies
- Support for large-scale KL divergence problems
- Integration with NumPy arrays
- Precompilation for consistent performance
Requirements
- Python 3.7+
- NumPy
- juliacall
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dualperspective-0.1.1.tar.gz.
File metadata
- Download URL: dualperspective-0.1.1.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a856b4a32503f5f7fac30c08a5bc9ff072d50f9cafe5c618206058e6b25ec3f
|
|
| MD5 |
b589152e5dfe333d8fa9749061b4bea7
|
|
| BLAKE2b-256 |
1218d9d0b10cfb23580204344888cc7f4942e0765c85c445b88ab36bdab63faf
|
File details
Details for the file dualperspective-0.1.1-py3-none-any.whl.
File metadata
- Download URL: dualperspective-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
716abd4b542ee4876e63a1655a2a9bcb5a6f8c818c86c7cc7e21a9c1b718b5d2
|
|
| MD5 |
df056455c35e2b0fd963a31614516d1a
|
|
| BLAKE2b-256 |
9e6b1ed55d6a3d6254b1e44aface2870e386a9e368ac487d8f3ee423ee26fcf1
|