FastQuat 0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,55 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ branches:
9
+ - main
10
+
11
+ concurrency:
12
+ group: ${{ github.workflow }}-${{ github.ref }}
13
+ cancel-in-progress: true
14
+
15
+ jobs:
16
+
17
+ pre-commit:
18
+ name: Run pre-commit hooks
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+ - name: Set up Python
23
+ uses: actions/setup-python@v5
24
+ with:
25
+ python-version: '3.x'
26
+ - name: Install dependencies
27
+ run: |
28
+ python -m pip install --upgrade pip
29
+ python -m pip install pre-commit
30
+ - name: Run pre-commit
31
+ run: pre-commit run --all-files --show-diff-on-failure --color=always
32
+
33
+ test:
34
+ name: Run tests on Python ${{ matrix.python-version }}
35
+ runs-on: ubuntu-latest
36
+ strategy:
37
+ matrix:
38
+ python-version: ['3.10', '3.11', '3.12', '3.13']
39
+
40
+ steps:
41
+ - name: Checkout code
42
+ uses: actions/checkout@v4
43
+
44
+ - name: Set up Python ${{ matrix.python-version }}
45
+ uses: actions/setup-python@v5
46
+ with:
47
+ python-version: ${{ matrix.python-version }}
48
+
49
+ - name: Install dependencies
50
+ run: |
51
+ python -m pip install --upgrade pip
52
+ pip install . --group dev
53
+
54
+ - name: Run tests
55
+ run: pytest -v
@@ -0,0 +1,54 @@
1
+ name: Release to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [created]
6
+
7
+ jobs:
8
+ publish:
9
+ name: Publish package to PyPI
10
+ runs-on: ubuntu-latest
11
+ environment: release
12
+
13
+ permissions:
14
+ id-token: write
15
+
16
+ steps:
17
+ - name: Checkout repository
18
+ uses: actions/checkout@v4
19
+ with:
20
+ fetch-depth: 0 # Full history for dynamic versioning
21
+
22
+ - name: Set up Python
23
+ uses: actions/setup-python@v5
24
+ with:
25
+ python-version: '3.12'
26
+
27
+ - name: Install uv
28
+ uses: astral-sh/setup-uv@v6
29
+ with:
30
+ enable-cache: true
31
+
32
+ - name: Debug Git tags and versioning
33
+ run: |
34
+ echo "Git tags:"
35
+ git tag -l
36
+ echo "Current tag:"
37
+ git describe --tags --exact-match HEAD || echo "No exact tag match"
38
+ echo "Version info:"
39
+ git describe --tags --always
40
+
41
+ - name: Clean uv cache for dynamic versioning
42
+ run: uv cache clean
43
+
44
+ - name: Build package
45
+ run: uv build
46
+
47
+ - name: Verify build artifacts
48
+ run: |
49
+ ls -la dist/
50
+ echo "Built artifacts:"
51
+ find dist/ -name "*.whl" -o -name "*.tar.gz" | head -10
52
+
53
+ - name: Publish to PyPI
54
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,9 @@
1
+ __pycache__/
2
+ dist/
3
+ build/
4
+ /.venv/
5
+ /.idea/
6
+
7
+ *.py[cod]
8
+ .ipynb_checkpoints/
9
+ .DS_Store
@@ -0,0 +1,35 @@
1
+ repos:
2
+ - repo: https://github.com/hadialqattan/pycln
3
+ rev: "v2.5.0"
4
+ hooks:
5
+ - id: pycln
6
+ args:
7
+ - --all
8
+
9
+ - repo: https://github.com/astral-sh/ruff-pre-commit
10
+ rev: "v0.11.8"
11
+ hooks:
12
+ - id: ruff
13
+ name: ruff linting
14
+ - id: ruff-format
15
+ name: ruff formatting
16
+
17
+ - repo: https://github.com/pre-commit/pre-commit-hooks
18
+ rev: 'v5.0.0'
19
+ hooks:
20
+ - id: trailing-whitespace
21
+ - id: end-of-file-fixer
22
+ - id: check-merge-conflict
23
+
24
+ - repo: https://github.com/pre-commit/mirrors-mypy
25
+ rev: 'v1.15.0'
26
+ hooks:
27
+ - id: mypy
28
+ additional_dependencies:
29
+ - jax
30
+ args:
31
+ - --strict
32
+ - --show-error-codes
33
+ - --enable-error-code=ignore-without-code
34
+ - --allow-untyped-calls
35
+ files: ^fastquat/
@@ -0,0 +1,42 @@
1
+ # Read the Docs configuration file
2
+ # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3
+
4
+ # Required
5
+ version: 2
6
+
7
+ # Set the OS, Python version, and other tools you might need
8
+ build:
9
+ os: ubuntu-22.04
10
+ tools:
11
+ python: "3.10"
12
+ # You can also specify other tool versions:
13
+ # nodejs: "19"
14
+ # rust: "1.64"
15
+ # golang: "1.19"
16
+
17
+ # Build documentation in the "docs/" directory with Sphinx
18
+ sphinx:
19
+ builder: html
20
+ configuration: docs/source/conf.py
21
+ fail_on_warning: false
22
+
23
+ # Optionally build your docs in additional formats such as PDF and ePub
24
+ formats:
25
+ - pdf
26
+ - epub
27
+
28
+ # Optional but recommended, declare the Python requirements required
29
+ # to build your documentation
30
+ # See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
31
+ python:
32
+ install:
33
+ - requirements: docs/requirements.txt
34
+ - method: pip
35
+ path: .
36
+ extra_requirements:
37
+ - dev
38
+
39
+ # Set the version of Python and other tools you might need
40
+ submodules:
41
+ include: all
42
+ recursive: true
fastquat-0.2/PKG-INFO ADDED
@@ -0,0 +1,127 @@
1
+ Metadata-Version: 2.4
2
+ Name: FastQuat
3
+ Version: 0.2
4
+ Summary: High-performance quaternions with JAX support
5
+ Author-email: Pierre Chanial <chanial@apc.in2p3.fr>
6
+ License-Expression: MIT
7
+ Requires-Python: >=3.10
8
+ Requires-Dist: jax[cuda12]>=0.4.0
9
+ Requires-Dist: jaxlib>=0.4.0
10
+ Description-Content-Type: text/markdown
11
+
12
+ # FastQuat - High-Performance Quaternions with JAX
13
+
14
+ [![PyPI version](https://img.shields.io/pypi/v/fastquat)](https://pypi.org/project/fastquat/)
15
+ [![Python versions](https://img.shields.io/pypi/pyversions/fastquat)](https://pypi.org/project/fastquat/)
16
+ [![Tests](https://github.com/CMBSciPol/fastquat/actions/workflows/tests.yml/badge.svg)](https://github.com/CMBSciPol/fastquat/actions)
17
+
18
+ FastQuat provides optimized quaternion operations with full JAX compatibility, featuring:
19
+
20
+ - 🚀 **Hardware-accelerated** computations (CPU/GPU/TPU)
21
+ - 🔄 **Automatic differentiation** support
22
+ - 🧩 **Seamless integration** with JAX transformations (`jit`, `grad`, `vmap`)
23
+ - 📦 **Efficient storage** using interleaved memory layout
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ pip install fastquat
29
+ ```
30
+
31
+ ## Quick Start
32
+
33
+ ```python
34
+ import jax.numpy as jnp
35
+ from fastquat import Quaternion
36
+
37
+ # Create quaternions
38
+ q1 = Quaternion.ones() # Identity quaternion
39
+ q2 = Quaternion(0.7071, 0.7071, 0.0, 0.0) # 90° rotation around x-axis
40
+
41
+ # Quaternion operations
42
+ q3 = q1 * q2 # Multiplication
43
+ q_inv = q1.inverse() # Inverse
44
+ q_norm = q1.normalize() # Normalization
45
+
46
+ # Rotate vectors
47
+ vector = jnp.array([1.0, 0.0, 0.0])
48
+ rotated = q2.rotate_vector(vector)
49
+
50
+ # Spherical interpolation (SLERP)
51
+ interpolated = q1.slerp(q2, t=0.5) # Halfway between q1 and q2
52
+ ```
53
+
54
+ ## Features
55
+
56
+ ### Core Operations
57
+ - **Quaternion arithmetic**: Addition, multiplication, conjugation, inverse
58
+ - **Normalization**: Efficient unit quaternion computation
59
+ - **Conversion**: To/from rotation matrices, Euler angles
60
+ - **Vector rotation**: Direct vector transformation
61
+
62
+ ### Advanced Interpolation
63
+ - **SLERP (Spherical Linear Interpolation)**: Smooth rotation interpolation
64
+ - Automatically handles shortest path selection
65
+ - Numerically stable for close quaternions
66
+ - Supports batched operations and array-valued parameters
67
+
68
+ ### JAX Integration
69
+ - **JIT compilation**: Compile quaternion operations for maximum performance
70
+ - **Automatic differentiation**: Compute gradients through quaternion operations
71
+ - **Vectorization**: Process batches of quaternions efficiently
72
+ - **Device support**: Run on CPU, GPU, or TPU
73
+
74
+ ## Performance
75
+
76
+ FastQuat is optimized for high-performance computing:
77
+ - Memory-efficient interleaved storage
78
+ - SIMD-optimized operations on supported hardware
79
+ - Zero-copy integration with JAX arrays
80
+ - Minimal Python overhead through JIT compilation
81
+
82
+ ## Examples
83
+
84
+ ### Basic Usage
85
+ ```python
86
+ import jax
87
+ import jax.numpy as jnp
88
+ from fastquat import Quaternion
89
+
90
+ # Create random quaternions
91
+ key = jax.random.PRNGKey(42)
92
+ q_batch = Quaternion.random(key, shape=(1000,))
93
+
94
+ # JIT-compiled batch operations
95
+ @jax.jit
96
+ def batch_rotate(quaternions, vectors):
97
+ return quaternions.rotate_vector(vectors)
98
+
99
+ vectors = jax.random.normal(key, (1000, 3))
100
+ rotated_batch = batch_rotate(q_batch, vectors)
101
+ ```
102
+
103
+ ### SLERP Animation
104
+ ```python
105
+ # Smooth rotation interpolation
106
+ q_start = Quaternion.ones()
107
+ q_end = Quaternion.from_rotation_matrix(rotation_matrix)
108
+
109
+ # Generate smooth interpolation
110
+ t_values = jnp.linspace(0, 1, 100)
111
+ interpolated_rotations = q_start.slerp(q_end, t_values)
112
+
113
+ # Apply to object vertices for smooth animation
114
+ animated_vertices = interpolated_rotations.rotate_vector(object_vertices)
115
+ ```
116
+
117
+ ## Documentation
118
+
119
+ Full documentation is available at [fastquat.readthedocs.io](https://fastquat.readthedocs.io)
120
+
121
+ ## Contributing
122
+
123
+ Contributions are welcome! Please see our [development guide](https://fastquat.readthedocs.io/en/latest/development.html) for details.
124
+
125
+ ## License
126
+
127
+ MIT License - see [LICENSE](LICENSE) file for details.
fastquat-0.2/README.md ADDED
@@ -0,0 +1,116 @@
1
+ # FastQuat - High-Performance Quaternions with JAX
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/fastquat)](https://pypi.org/project/fastquat/)
4
+ [![Python versions](https://img.shields.io/pypi/pyversions/fastquat)](https://pypi.org/project/fastquat/)
5
+ [![Tests](https://github.com/CMBSciPol/fastquat/actions/workflows/tests.yml/badge.svg)](https://github.com/CMBSciPol/fastquat/actions)
6
+
7
+ FastQuat provides optimized quaternion operations with full JAX compatibility, featuring:
8
+
9
+ - 🚀 **Hardware-accelerated** computations (CPU/GPU/TPU)
10
+ - 🔄 **Automatic differentiation** support
11
+ - 🧩 **Seamless integration** with JAX transformations (`jit`, `grad`, `vmap`)
12
+ - 📦 **Efficient storage** using interleaved memory layout
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ pip install fastquat
18
+ ```
19
+
20
+ ## Quick Start
21
+
22
+ ```python
23
+ import jax.numpy as jnp
24
+ from fastquat import Quaternion
25
+
26
+ # Create quaternions
27
+ q1 = Quaternion.ones() # Identity quaternion
28
+ q2 = Quaternion(0.7071, 0.7071, 0.0, 0.0) # 90° rotation around x-axis
29
+
30
+ # Quaternion operations
31
+ q3 = q1 * q2 # Multiplication
32
+ q_inv = q1.inverse() # Inverse
33
+ q_norm = q1.normalize() # Normalization
34
+
35
+ # Rotate vectors
36
+ vector = jnp.array([1.0, 0.0, 0.0])
37
+ rotated = q2.rotate_vector(vector)
38
+
39
+ # Spherical interpolation (SLERP)
40
+ interpolated = q1.slerp(q2, t=0.5) # Halfway between q1 and q2
41
+ ```
42
+
43
+ ## Features
44
+
45
+ ### Core Operations
46
+ - **Quaternion arithmetic**: Addition, multiplication, conjugation, inverse
47
+ - **Normalization**: Efficient unit quaternion computation
48
+ - **Conversion**: To/from rotation matrices, Euler angles
49
+ - **Vector rotation**: Direct vector transformation
50
+
51
+ ### Advanced Interpolation
52
+ - **SLERP (Spherical Linear Interpolation)**: Smooth rotation interpolation
53
+ - Automatically handles shortest path selection
54
+ - Numerically stable for close quaternions
55
+ - Supports batched operations and array-valued parameters
56
+
57
+ ### JAX Integration
58
+ - **JIT compilation**: Compile quaternion operations for maximum performance
59
+ - **Automatic differentiation**: Compute gradients through quaternion operations
60
+ - **Vectorization**: Process batches of quaternions efficiently
61
+ - **Device support**: Run on CPU, GPU, or TPU
62
+
63
+ ## Performance
64
+
65
+ FastQuat is optimized for high-performance computing:
66
+ - Memory-efficient interleaved storage
67
+ - SIMD-optimized operations on supported hardware
68
+ - Zero-copy integration with JAX arrays
69
+ - Minimal Python overhead through JIT compilation
70
+
71
+ ## Examples
72
+
73
+ ### Basic Usage
74
+ ```python
75
+ import jax
76
+ import jax.numpy as jnp
77
+ from fastquat import Quaternion
78
+
79
+ # Create random quaternions
80
+ key = jax.random.PRNGKey(42)
81
+ q_batch = Quaternion.random(key, shape=(1000,))
82
+
83
+ # JIT-compiled batch operations
84
+ @jax.jit
85
+ def batch_rotate(quaternions, vectors):
86
+ return quaternions.rotate_vector(vectors)
87
+
88
+ vectors = jax.random.normal(key, (1000, 3))
89
+ rotated_batch = batch_rotate(q_batch, vectors)
90
+ ```
91
+
92
+ ### SLERP Animation
93
+ ```python
94
+ # Smooth rotation interpolation
95
+ q_start = Quaternion.ones()
96
+ q_end = Quaternion.from_rotation_matrix(rotation_matrix)
97
+
98
+ # Generate smooth interpolation
99
+ t_values = jnp.linspace(0, 1, 100)
100
+ interpolated_rotations = q_start.slerp(q_end, t_values)
101
+
102
+ # Apply to object vertices for smooth animation
103
+ animated_vertices = interpolated_rotations.rotate_vector(object_vertices)
104
+ ```
105
+
106
+ ## Documentation
107
+
108
+ Full documentation is available at [fastquat.readthedocs.io](https://fastquat.readthedocs.io)
109
+
110
+ ## Contributing
111
+
112
+ Contributions are welcome! Please see our [development guide](https://fastquat.readthedocs.io/en/latest/development.html) for details.
113
+
114
+ ## License
115
+
116
+ MIT License - see [LICENSE](LICENSE) file for details.
@@ -0,0 +1 @@
1
+ /build
@@ -0,0 +1,20 @@
1
+ # Minimal makefile for Sphinx documentation
2
+ #
3
+
4
+ # You can set these variables from the command line, and also
5
+ # from the environment for the first two.
6
+ SPHINXOPTS ?=
7
+ SPHINXBUILD ?= sphinx-build
8
+ SOURCEDIR = source
9
+ BUILDDIR = build
10
+
11
+ # Put it first so that "make" without argument is like "make help".
12
+ help:
13
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14
+
15
+ .PHONY: help Makefile
16
+
17
+ # Catch-all target: route all unknown targets to Sphinx using the new
18
+ # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19
+ %: Makefile
20
+ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@@ -0,0 +1,17 @@
1
+ # Documentation dependencies for FastQuat
2
+ # This file ensures compatibility with Read the Docs and other documentation platforms
3
+ # that don't yet fully support PEP 735 dependency groups
4
+
5
+ # Core dependencies
6
+ jax[cuda12]>=0.4.0
7
+ jaxlib>=0.4.0
8
+
9
+ # Documentation-specific dependencies
10
+ sphinx>=7.0.0
11
+ sphinx-rtd-theme>=1.3.0
12
+ myst-parser>=2.0.0
13
+ nbsphinx>=0.9.0
14
+ jupyter>=1.0.0
15
+ matplotlib>=3.7.0
16
+ numpy>=1.24.0
17
+ pillow>=9.0.0
@@ -0,0 +1,62 @@
1
+ fastquat.Quaternion
2
+ ===================
3
+
4
+ .. currentmodule:: fastquat
5
+
6
+ .. autoclass:: Quaternion
7
+
8
+
9
+ .. automethod:: __init__
10
+
11
+
12
+ .. rubric:: Methods
13
+
14
+ .. autosummary::
15
+
16
+ ~Quaternion.__init__
17
+ ~Quaternion.block_until_ready
18
+ ~Quaternion.conj
19
+ ~Quaternion.conjugate
20
+ ~Quaternion.devices
21
+ ~Quaternion.exp
22
+ ~Quaternion.flatten
23
+ ~Quaternion.from_array
24
+ ~Quaternion.from_rotation_matrix
25
+ ~Quaternion.from_scalar_vector
26
+ ~Quaternion.full
27
+ ~Quaternion.log
28
+ ~Quaternion.norm
29
+ ~Quaternion.normalize
30
+ ~Quaternion.ones
31
+ ~Quaternion.random
32
+ ~Quaternion.ravel
33
+ ~Quaternion.reshape
34
+ ~Quaternion.rotate_vector
35
+ ~Quaternion.slerp
36
+ ~Quaternion.squeeze
37
+ ~Quaternion.to_components
38
+ ~Quaternion.to_rotation_matrix
39
+ ~Quaternion.tree_flatten
40
+ ~Quaternion.tree_unflatten
41
+ ~Quaternion.zeros
42
+
43
+
44
+
45
+
46
+
47
+ .. rubric:: Attributes
48
+
49
+ .. autosummary::
50
+
51
+ ~Quaternion.device
52
+ ~Quaternion.dtype
53
+ ~Quaternion.itemsize
54
+ ~Quaternion.nbytes
55
+ ~Quaternion.ndim
56
+ ~Quaternion.shape
57
+ ~Quaternion.size
58
+ ~Quaternion.vector
59
+ ~Quaternion.w
60
+ ~Quaternion.x
61
+ ~Quaternion.y
62
+ ~Quaternion.z
@@ -0,0 +1,21 @@
1
+ API Reference
2
+ =============
3
+
4
+ This section contains the complete API documentation for FastQuat.
5
+
6
+ .. toctree::
7
+ :maxdepth: 2
8
+
9
+ quaternion
10
+
11
+ Core Classes
12
+ ------------
13
+
14
+ .. autosummary::
15
+ :toctree: generated
16
+
17
+ fastquat.Quaternion
18
+
19
+ The :class:`fastquat.Quaternion` class is the main interface for quaternion operations
20
+ in FastQuat. It provides all essential quaternion arithmetic, conversions, and
21
+ specialized operations like SLERP interpolation.
@@ -0,0 +1,61 @@
1
+ Quaternion Class
2
+ ================
3
+
4
+ .. automodule:: fastquat.quaternion
5
+ :members:
6
+ :undoc-members:
7
+ :show-inheritance:
8
+
9
+ The :class:`Quaternion` class provides a comprehensive interface for quaternion operations
10
+ optimized for JAX. All methods are compatible with JAX transformations including JIT
11
+ compilation, automatic differentiation, and vectorization.
12
+
13
+ Constructor Methods
14
+ -------------------
15
+
16
+ .. automethod:: fastquat.Quaternion.__init__
17
+ .. automethod:: fastquat.Quaternion.from_array
18
+ .. automethod:: fastquat.Quaternion.from_scalar_vector
19
+ .. automethod:: fastquat.Quaternion.from_rotation_matrix
20
+ .. automethod:: fastquat.Quaternion.zeros
21
+ .. automethod:: fastquat.Quaternion.ones
22
+ .. automethod:: fastquat.Quaternion.full
23
+ .. automethod:: fastquat.Quaternion.random
24
+
25
+ Properties
26
+ ----------
27
+
28
+ .. autoattribute:: fastquat.Quaternion.w
29
+ .. autoattribute:: fastquat.Quaternion.x
30
+ .. autoattribute:: fastquat.Quaternion.y
31
+ .. autoattribute:: fastquat.Quaternion.z
32
+ .. autoattribute:: fastquat.Quaternion.vector
33
+ .. autoattribute:: fastquat.Quaternion.shape
34
+ .. autoattribute:: fastquat.Quaternion.dtype
35
+
36
+ Core Operations
37
+ ---------------
38
+
39
+ .. automethod:: fastquat.Quaternion.norm
40
+ .. automethod:: fastquat.Quaternion.normalize
41
+ .. automethod:: fastquat.Quaternion.inverse
42
+ .. automethod:: fastquat.Quaternion.conjugate
43
+ .. automethod:: fastquat.Quaternion.conj
44
+
45
+ Rotation Operations
46
+ -------------------
47
+
48
+ .. automethod:: fastquat.Quaternion.to_rotation_matrix
49
+ .. automethod:: fastquat.Quaternion.rotate_vector
50
+
51
+ Interpolation
52
+ -------------
53
+
54
+ .. automethod:: fastquat.Quaternion.slerp
55
+
56
+ Advanced Operations
57
+ -------------------
58
+
59
+ .. automethod:: fastquat.Quaternion.log
60
+ .. automethod:: fastquat.Quaternion.exp
61
+ .. automethod:: fastquat.Quaternion.__pow__