Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Tests

on:
push:
branches: [ master, main, develop ]
pull_request:
branches: [ master, main, develop ]

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-cov
pip install -e .

- name: Download knots database
run: |
python -c "import pyknotid.catalogue; pyknotid.catalogue.download_database()"

- name: Run tests
run: |
pytest -v --tb=short --cov=pyknotid --cov-report=xml --cov-report=term

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
26 changes: 25 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
*.pyc
*.so
*.c
*.db
*.db
dev/

# Build and distribution
*.egg-info/
dist/
build/
__pycache__/

# Documentation
doc/_build/
doc/_static/

# Testing
.pytest_cache/
.coverage
coverage.xml
htmlcov/

# IDE
.vscode/
.idea/
*.swp
*.swo
*~
2 changes: 0 additions & 2 deletions .projectile

This file was deleted.

18 changes: 18 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Read the Docs configuration file for pyknotid
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

version: 2

build:
os: ubuntu-22.04
tools:
python: "3.8"

sphinx:
configuration: doc/conf.py

python:
install:
- requirements: doc/requirements.txt
- method: pip
path: .
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

7 changes: 7 additions & 0 deletions CITATION.bib
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@Misc{pyknotid,
author = {Alexander J Taylor and other SPOCK contributors},
title = {pyknotid knot identification toolkit},
howpublished = {\url{https://github.com/SPOCKnots/pyknotid}},
note = {Accessed YYYY-MM-DD},
year = 2017,
}
29 changes: 29 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
cff-version: 1.2.0
message: "If you use pyknotid in your research, please cite it as below."
title: "pyknotid knot identification toolkit"
version: 0.5.4
date-released: 2017-01-01
url: "https://github.com/SPOCKnots/pyknotid"
repository-code: "https://github.com/SPOCKnots/pyknotid"
license: MIT
authors:
- family-names: "Taylor"
given-names: "Alexander J"
email: "alexander.taylor@bristol.ac.uk"
- name: "SPOCK contributors"
keywords:
- knot-theory
- topology
- mathematics
- knot-identification
- linking
abstract: "Python modules for detecting and measuring knotting and linking. pyknotid can analyse space-curves, i.e. sets of points in three-dimensions, or can parse standard topological representations of knot diagrams."
preferred-citation:
type: software
title: "pyknotid knot identification toolkit"
authors:
- family-names: "Taylor"
given-names: "Alexander J"
- name: "other SPOCK contributors"
year: 2017
url: "https://github.com/SPOCKnots/pyknotid"
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Alexander Taylor and other contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
7 changes: 0 additions & 7 deletions LICENSE.txt

This file was deleted.

5 changes: 5 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include README.md
include LICENSE.txt
include CITATION.cff
include CITATION.bib
recursive-include pyknotid *.tmpl *.pov *.py
153 changes: 153 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# Pyknotid

[![PyPI version](https://img.shields.io/pypi/v/pyknotid.svg)](https://pypi.org/project/pyknotid/)
[![Documentation Status](https://readthedocs.org/projects/pyknotid/badge/?version=latest)](https://pyknotid.readthedocs.io/en/latest/?badge=latest)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Python modules for detecting and measuring knotting and linking. pyknotid can analyse space-curves (sets of points in three dimensions) or parse standard topological representations of knot diagrams.

<p align="center">
<img src="doc/k10_92_ideal_small.png" alt="The knot 10_92, visualised by pyknotid" width="300"/>
</p>

## Features

- **Knot identification** from space curves or topological representations
- **Polynomial invariants** (Alexander, Jones, HOMFLY-PT, Kauffman)
- **Vassiliev invariants** computation
- **Knot simplification** using octree algorithms
- **Visualization** of knots in 3D
- **Database** of known knots for identification
- **High performance** with optional Numba JIT compilation (2-3x faster)

## Installation

pyknotid requires Python 3.8 or later. Install it with:

```bash
pip install pyknotid
```

**For best performance**, install with Numba support:

```bash
pip install pyknotid[performance]
```

This enables JIT-compiled high-performance numerical computations (2-3x faster). Without Numba, pyknotid will work but use slower pure Python fallbacks.

### Development Installation

To try the latest development version, clone this repository and run:

```bash
git clone https://github.com/SPOCKnots/pyknotid.git
cd pyknotid
pip install -e .
```

For development with all optional dependencies:

```bash
pip install -e ".[dev]"
```

## Quick Start

```python
import pyknotid.spacecurves as sp
import pyknotid.make as mk

# Create a figure-eight knot
k = sp.Knot(mk.figure_eight(num_points=100))

# Visualize it
k.plot()

# Calculate the Alexander polynomial at t=-1
k.alexander_polynomial(-1)
# Output: 6.9999999999999991

# Calculate the symbolic Alexander polynomial
import sympy as sym
t = sym.var('t')
k.alexander_polynomial(t)
# Output: 2/t - 3/t**2 + 2/t**3

# Simplify the knot representation
k.octree_simplify(5)
# Run 0 of 5, 100 points remain
# Run 1 of 5, 98 points remain
# ...
# Reduced to 77 points

k.plot()
```

## Documentation

Full documentation is available at [pyknotid.readthedocs.io](http://pyknotid.readthedocs.io).

## Requirements

The following dependencies are automatically installed:

- numpy >= 1.19
- networkx >= 2.5
- planarity >= 0.4
- peewee >= 3.14
- vispy >= 0.6
- sympy >= 1.8
- appdirs >= 1.4
- requests >= 2.25
- tqdm >= 4.60

### Optional Dependencies

- **numba >= 0.55** (recommended for performance): Install with `pip install pyknotid[performance]`
- **pytest, pytest-cov, black, flake8, mypy** (for development): Install with `pip install pyknotid[dev]`
- **sphinx, sphinx-rtd-theme** (for documentation): Install with `pip install pyknotid[docs]`

## About

pyknotid was originally developed as part of the Leverhulme Trust Research Programme Grant RP2013-K-009: Scientific Properties of Complex Knots (SPOCK), a collaboration between the University of Bristol and Durham University in the UK.

For more information, see the [SPOCK homepage](http://www.maths.dur.ac.uk/spock/index.html/).

## Citation

If you use pyknotid in your research, please cite it. See [CITATION.cff](CITATION.cff) for citation information, or use:

```bibtex
@Misc{pyknotid,
author = {Alexander J Taylor and other SPOCK contributors},
title = {pyknotid knot identification toolkit},
howpublished = {\url{https://github.com/SPOCKnots/pyknotid}},
year = 2017,
}
```

For more details, see our [citation guidelines](http://pyknotid.readthedocs.io/en/latest/sources/about.html#cite-us).

## License

pyknotid is released under the [MIT License](LICENSE.txt).

## Contributing

Contributions are welcome! Please feel free to:

- Report bugs or request features via [GitHub Issues](https://github.com/SPOCKnots/pyknotid/issues)
- Submit pull requests
- Improve documentation

## Contact

Questions or comments are welcome. Please do not hesitate to open an issue or pull request on GitHub.

## Links

- **Homepage**: https://github.com/SPOCKnots/pyknotid
- **Documentation**: http://pyknotid.readthedocs.io
- **PyPI**: https://pypi.org/project/pyknotid/
- **Bug Tracker**: https://github.com/SPOCKnots/pyknotid/issues
Loading