Skip to main content

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:

  1. Install Julia if not already installed (via juliacall)
  2. Install the DualPerspective.jl Julia package
  3. 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 = DualPerspectiveModel(A, b)
model = 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


Download files

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

Source Distribution

dualperspective-0.1.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

dualperspective-0.1.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file dualperspective-0.1.0.tar.gz.

File metadata

  • Download URL: dualperspective-0.1.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for dualperspective-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c70882214a3118315736812de1c1dcfbe6c06fd70a4ca3ad5d8503adf62c6607
MD5 b84be63e1657793209f49c8522e131dc
BLAKE2b-256 a5d0596e95004227f0180d747460ac160e30feae63142206373a7f747e62c292

See more details on using hashes here.

File details

Details for the file dualperspective-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for dualperspective-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 196596b9566a6820c50c95081f0591d50a3208fbd0659e07b7bb2958beb7de86
MD5 b5b2ca8ad7415b126693731caee15d36
BLAKE2b-256 58676bbdda324a1f27cbb3c8e9e7df88ac9fd5c266747f664e939162c6c17b13

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