Skip to main content

Dependency-free Python interface for cppkh with runtime C++ compilation.

Project description

cppkh-interface

cppkh-interface is a Python package for computing integer Khovanov homology with the C++ cppkh implementation.

The package has no runtime Python-package dependencies. Link crossing signs, PD validation, R1 removal, and nugatory-crossing removal all use the bundled canonical cppkh C++ source and its SageMath-compatible orientation rules.

The package is compatible with the main javakh-interface function:

import cppkh_interface

pd_code = [[1, 5, 2, 4], [3, 1, 4, 6], [5, 3, 6, 2]]
print(cppkh_interface.solve_khovanov(pd_code, de_r1=True, de_k8=True))
print(cppkh_interface.solve_many_khovanov([pd_code, pd_code]))

For a multi-component oriented link, callers can compute several explicit crossing-sign variants without changing the existing APIs:

from cppkh_interface import compute_signed_variants

hopf = [[2, 3, 1, 4], [4, 1, 3, 2]]
results = compute_signed_variants(hopf, [[-1, -1], [1, 1]])
assert len(results) == 2

Each sign row must contain exactly one -1 or 1 for every crossing. This operation deliberately disables PD simplification because removing a crossing would invalidate the positional sign mapping. solve_khovanov and solve_many_khovanov retain their original signatures, inferred-sign behavior, and simplification defaults.

Unlike wrappers that ship a prebuilt DLL or shared object, this package ships the cppkh C++ source file in built distributions and compiles a local executable on first use using only Python's standard library. The compiled executable is cached for later calls.

In the repository checkout, the package does not keep a committed backup copy of the C++ source. The build backend copies ../../src/main.cpp into the package data directory only while the PEP 517 build is running, then removes that temporary copy.

Install

pip install cppkh-interface

A C++14 compiler must be available at runtime. The package looks at CPPKH_INTERFACE_CXX, then CXX, then searches PATH for g++, clang++, or c++. To select a compiler explicitly:

CPPKH_INTERFACE_CXX=clang++ python your_script.py

Windows PowerShell:

$env:CPPKH_INTERFACE_CXX = "C:\path\to\g++.exe"
python your_script.py

Build And Publish

From this directory:

python -m build
poetry publish

Do not use poetry build or poetry publish --build: Poetry's direct builder bypasses the source-synchronizing PEP 517 backend. Build first with python -m build, inspect/test the wheel, then publish the existing artifacts.

For local testing:

poetry run python -m cppkh_interface "[[1,5,2,4], [3,1,4,6], [5,3,6,2]]"

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

cppkh_interface-0.2.1.tar.gz (38.5 kB view details)

Uploaded Source

Built Distribution

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

cppkh_interface-0.2.1-py3-none-any.whl (38.6 kB view details)

Uploaded Python 3

File details

Details for the file cppkh_interface-0.2.1.tar.gz.

File metadata

  • Download URL: cppkh_interface-0.2.1.tar.gz
  • Upload date:
  • Size: 38.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.11.15 Windows/10

File hashes

Hashes for cppkh_interface-0.2.1.tar.gz
Algorithm Hash digest
SHA256 638309976631988ddd02e136f395399002947b145979740694f09d374ec5942d
MD5 b962261709698ff00ab417f6c887aee7
BLAKE2b-256 7d6e5755c848735103ccfc2e59888e6ca797a2ee668cf4b091a35b79f268a1f3

See more details on using hashes here.

File details

Details for the file cppkh_interface-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: cppkh_interface-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 38.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.11.15 Windows/10

File hashes

Hashes for cppkh_interface-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 361f7b1122f5238e939717f3c58ad3120af8007242e53e4727c372ea0f6075b9
MD5 f63759937921166f32fef8a3b8da2234
BLAKE2b-256 3485061e2dbea7529de4035b440389335d5d4c8196b806bb4998e66d6459c72a

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