passagemath-homfly

raw JSON →
10.8.4 verified Mon Apr 27 auth: no python

passagemath-homfly provides computation of Homfly polynomials for knots and links using libhomfly, integrated with the passagemath ecosystem. Current version 10.8.4, requiring Python ≥3.11 and <3.15. Follows passagemath release cadence; stable maintenance.

pip install passagemath-homfly
error ImportError: cannot import name 'link_homfly_polynomial' from 'passagemath.homfly'
cause Incorrect import path or passagemath-homfly not installed.
fix
Run 'pip install passagemath-homfly' then use 'from passagemath.homfly import link_homfly_polynomial'
error TypeError: expected a Sage knot or link, got str
cause Passing a string (e.g., '3_1') directly to link_homfly_polynomial.
fix
Create a Knot object: Knot('3_1') before passing.
error ModuleNotFoundError: No module named 'sage'
cause SageMath environment not installed or not activated.
fix
Install passagemath-sage or full SageMath, or run within a SageMath environment (e.g., 'sage -python').
deprecated Direct import from 'passagemath.homfly' may be deprecated in future releases. Use full import path as shown in quickstart.
fix Always use 'from passagemath.homfly import link_homfly_polynomial'
gotcha Knot/link must be a SageMath Knot or Link object, not a string. Common mistake: passing a knot name as string directly.
fix Wrap knot name in Knot('3_1') or Link().
breaking Python 3.11+ required. Versions prior to 10.8 may fail on Python 3.12+ due to C library incompatibility.
fix Upgrade to 10.8.4 and use Python 3.11-3.14.

Compute the Homfly polynomial of a trefoil knot. Requires SageMath environment.

from sage.knots.knot import Knot
from passagemath.homfly import link_homfly_polynomial

# Create a trefoil knot (3_1)
trefoil = Knot('3_1')
# Compute Homfly polynomial
poly = link_homfly_polynomial(trefoil)
print(poly)