bispectrum 0.3.0__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,99 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ *.egg-info/
24
+ *.egg
25
+
26
+ # PyInstaller
27
+ *.manifest
28
+ *.spec
29
+
30
+ # Installer logs
31
+ pip-log.txt
32
+ pip-delete-this-directory.txt
33
+
34
+ # Unit test / coverage reports
35
+ htmlcov/
36
+ .tox/
37
+ .nox/
38
+ .coverage
39
+ .coverage.*
40
+ .cache
41
+ nosetests.xml
42
+ coverage.xml
43
+ *.cover
44
+ *.py,cover
45
+ .hypothesis/
46
+ .pytest_cache/
47
+
48
+ # Translations
49
+ *.mo
50
+ *.pot
51
+
52
+ # Environments
53
+ .env
54
+ .venv
55
+ env/
56
+ venv/
57
+ ENV/
58
+ env.bak/
59
+ venv.bak/
60
+
61
+ # Spyder project settings
62
+ .spyderproject
63
+ .spyproject
64
+
65
+ # Rope project settings
66
+ .ropeproject
67
+
68
+ # mkdocs documentation
69
+ /site
70
+
71
+ # mypy
72
+ .mypy_cache/
73
+ .dmypy.json
74
+ dmypy.json
75
+
76
+ # ruff
77
+ .ruff_cache/
78
+
79
+ # IDE
80
+ .idea/
81
+ .vscode/
82
+ *.swp
83
+ *.swo
84
+
85
+ # OS
86
+ .DS_Store
87
+ Thumbs.db
88
+
89
+ # uv
90
+ uv.lock
91
+
92
+ # LaTeX build artifacts
93
+ *.aux
94
+ *.log
95
+ *.nav
96
+ *.out
97
+ *.snm
98
+ *.toc
99
+ *.vrb
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Johan Mathe and the bispectrum authors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,125 @@
1
+ Metadata-Version: 2.4
2
+ Name: bispectrum
3
+ Version: 0.3.0
4
+ Summary: Bispectrum analysis for machine learning
5
+ Project-URL: Homepage, https://github.com/geometric-intelligence/bispectrum
6
+ Project-URL: Repository, https://github.com/geometric-intelligence/bispectrum
7
+ Project-URL: Issues, https://github.com/geometric-intelligence/bispectrum/issues
8
+ Author-email: Johan Mathe <johan.mathe@gmail.com>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: deep learning,machine learning,neural networks,scientific computations,tensor manipulation
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Requires-Python: >=3.12
20
+ Requires-Dist: numpy>=1.22.4
21
+ Requires-Dist: torch-harmonics>=0.9
22
+ Requires-Dist: torch>=2.10
23
+ Provides-Extra: dev
24
+ Requires-Dist: mypy>=1.5.0; extra == 'dev'
25
+ Requires-Dist: pre-commit>=3.3.3; extra == 'dev'
26
+ Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
27
+ Requires-Dist: pytest-xdist>=3.5.0; extra == 'dev'
28
+ Requires-Dist: pytest>=8; extra == 'dev'
29
+ Requires-Dist: ruff>=0.4.0; extra == 'dev'
30
+ Provides-Extra: experiments
31
+ Requires-Dist: h5py; extra == 'experiments'
32
+ Requires-Dist: matplotlib>=3.7.0; extra == 'experiments'
33
+ Requires-Dist: medmnist; extra == 'experiments'
34
+ Requires-Dist: scipy>=1.10; extra == 'experiments'
35
+ Requires-Dist: torchvision; extra == 'experiments'
36
+ Description-Content-Type: text/markdown
37
+
38
+ # bispectrum
39
+
40
+ [![Tests](https://github.com/geometric-intelligence/bispectrum/actions/workflows/tests.yml/badge.svg)](https://github.com/geometric-intelligence/bispectrum/actions/workflows/tests.yml)
41
+ [![Pre-commit](https://github.com/geometric-intelligence/bispectrum/actions/workflows/pre-commit.yml/badge.svg)](https://github.com/geometric-intelligence/bispectrum/actions/workflows/pre-commit.yml)
42
+ [![codecov](https://codecov.io/github/geometric-intelligence/bispectrum/graph/badge.svg?token=J6GGY4VK1E)](https://codecov.io/github/geometric-intelligence/bispectrum)
43
+
44
+ Bispectrum analysis for machine learning.
45
+
46
+ ## Installation
47
+
48
+ ```bash
49
+ pip install bispectrum
50
+ ```
51
+
52
+ Or with [uv](https://github.com/astral-sh/uv):
53
+
54
+ ```bash
55
+ uv pip install bispectrum
56
+ ```
57
+
58
+ ### Development
59
+
60
+ ```bash
61
+ git clone https://github.com/geometric-intelligence/bispectrum.git
62
+ cd bispectrum
63
+ uv pip install -e ".[dev]"
64
+ pre-commit install
65
+ ```
66
+
67
+ ### Pre-commit Hooks
68
+
69
+ This project uses [pre-commit](https://pre-commit.com/) for code quality checks. After installing dev dependencies, the hooks run automatically on each commit.
70
+
71
+ ```bash
72
+ # Run hooks on all files (useful for first-time setup or CI)
73
+ pre-commit run --all-files
74
+
75
+ # Run a specific hook
76
+ pre-commit run ruff --all-files
77
+
78
+ # Update hooks to latest versions
79
+ pre-commit autoupdate
80
+ ```
81
+
82
+ ## Usage
83
+
84
+ ### Cyclic group on itself
85
+
86
+ ```python
87
+ from bispectrum import CnonCn
88
+
89
+ bsp = CnonCn(n=8)
90
+ f = torch.randn(4, 8) # signal on Z/8Z
91
+ beta = bsp(f) # shape (4, 8), complex64
92
+ f_rec = bsp.invert(beta) # reconstructed up to cyclic shift
93
+ ```
94
+
95
+ ### SO(3) on the 2-sphere
96
+
97
+ ```python
98
+ from bispectrum import SO3onS2
99
+
100
+ # Selective bispectrum: O(L²) entries with generic completeness
101
+ bsp = SO3onS2(lmax=5, nlat=64, nlon=128, selective=True)
102
+ f = torch.randn(1, 64, 128) # signal on S²
103
+ beta = bsp(f) # shape (1, 35), complex64
104
+
105
+ # Full bispectrum: O(L³) entries
106
+ bsp_full = SO3onS2(lmax=5, nlat=64, nlon=128, selective=False)
107
+ beta_full = bsp_full(f) # shape (1, 69), complex64
108
+ ```
109
+
110
+ ### Octahedral group
111
+
112
+ ```python
113
+ from bispectrum import OctaonOcta
114
+
115
+ bsp = OctaonOcta()
116
+ f = torch.randn(4, 24) # signal on O (|O| = 24)
117
+ beta = bsp(f) # shape (4, 172), complex64
118
+ f_rec = bsp.invert(beta) # reconstructed up to group action
119
+ ```
120
+
121
+ See [DESIGN.md](DESIGN.md) for the full API and all supported groups.
122
+
123
+ ## License
124
+
125
+ MIT
@@ -0,0 +1,88 @@
1
+ # bispectrum
2
+
3
+ [![Tests](https://github.com/geometric-intelligence/bispectrum/actions/workflows/tests.yml/badge.svg)](https://github.com/geometric-intelligence/bispectrum/actions/workflows/tests.yml)
4
+ [![Pre-commit](https://github.com/geometric-intelligence/bispectrum/actions/workflows/pre-commit.yml/badge.svg)](https://github.com/geometric-intelligence/bispectrum/actions/workflows/pre-commit.yml)
5
+ [![codecov](https://codecov.io/github/geometric-intelligence/bispectrum/graph/badge.svg?token=J6GGY4VK1E)](https://codecov.io/github/geometric-intelligence/bispectrum)
6
+
7
+ Bispectrum analysis for machine learning.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ pip install bispectrum
13
+ ```
14
+
15
+ Or with [uv](https://github.com/astral-sh/uv):
16
+
17
+ ```bash
18
+ uv pip install bispectrum
19
+ ```
20
+
21
+ ### Development
22
+
23
+ ```bash
24
+ git clone https://github.com/geometric-intelligence/bispectrum.git
25
+ cd bispectrum
26
+ uv pip install -e ".[dev]"
27
+ pre-commit install
28
+ ```
29
+
30
+ ### Pre-commit Hooks
31
+
32
+ This project uses [pre-commit](https://pre-commit.com/) for code quality checks. After installing dev dependencies, the hooks run automatically on each commit.
33
+
34
+ ```bash
35
+ # Run hooks on all files (useful for first-time setup or CI)
36
+ pre-commit run --all-files
37
+
38
+ # Run a specific hook
39
+ pre-commit run ruff --all-files
40
+
41
+ # Update hooks to latest versions
42
+ pre-commit autoupdate
43
+ ```
44
+
45
+ ## Usage
46
+
47
+ ### Cyclic group on itself
48
+
49
+ ```python
50
+ from bispectrum import CnonCn
51
+
52
+ bsp = CnonCn(n=8)
53
+ f = torch.randn(4, 8) # signal on Z/8Z
54
+ beta = bsp(f) # shape (4, 8), complex64
55
+ f_rec = bsp.invert(beta) # reconstructed up to cyclic shift
56
+ ```
57
+
58
+ ### SO(3) on the 2-sphere
59
+
60
+ ```python
61
+ from bispectrum import SO3onS2
62
+
63
+ # Selective bispectrum: O(L²) entries with generic completeness
64
+ bsp = SO3onS2(lmax=5, nlat=64, nlon=128, selective=True)
65
+ f = torch.randn(1, 64, 128) # signal on S²
66
+ beta = bsp(f) # shape (1, 35), complex64
67
+
68
+ # Full bispectrum: O(L³) entries
69
+ bsp_full = SO3onS2(lmax=5, nlat=64, nlon=128, selective=False)
70
+ beta_full = bsp_full(f) # shape (1, 69), complex64
71
+ ```
72
+
73
+ ### Octahedral group
74
+
75
+ ```python
76
+ from bispectrum import OctaonOcta
77
+
78
+ bsp = OctaonOcta()
79
+ f = torch.randn(4, 24) # signal on O (|O| = 24)
80
+ beta = bsp(f) # shape (4, 172), complex64
81
+ f_rec = bsp.invert(beta) # reconstructed up to group action
82
+ ```
83
+
84
+ See [DESIGN.md](DESIGN.md) for the full API and all supported groups.
85
+
86
+ ## License
87
+
88
+ MIT
@@ -0,0 +1,114 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [tool.hatch.build.targets.wheel]
6
+ packages = ["src/bispectrum"]
7
+
8
+ [tool.hatch.build.targets.wheel.sources]
9
+ "src" = ""
10
+
11
+ [tool.hatch.build]
12
+ include = [
13
+ "src/bispectrum/**/*.py",
14
+ "src/bispectrum/**/*.json",
15
+ ]
16
+
17
+ [project]
18
+ name = "bispectrum"
19
+ version = "0.3.0"
20
+ description = "Bispectrum analysis for machine learning"
21
+ readme = "README.md"
22
+ license = "MIT"
23
+ requires-python = ">=3.12"
24
+ authors = [{ name = "Johan Mathe", email = "johan.mathe@gmail.com" }]
25
+ keywords = [
26
+ "deep learning",
27
+ "neural networks",
28
+ "tensor manipulation",
29
+ "machine learning",
30
+ "scientific computations",
31
+ ]
32
+ classifiers = [
33
+ "Development Status :: 3 - Alpha",
34
+ "Intended Audience :: Science/Research",
35
+ "License :: OSI Approved :: MIT License",
36
+ "Operating System :: OS Independent",
37
+ "Programming Language :: Python :: 3.12",
38
+ "Programming Language :: Python :: 3.13",
39
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
40
+ ]
41
+
42
+ dependencies = [
43
+ "torch>=2.10",
44
+ "numpy>=1.22.4",
45
+ "torch-harmonics>=0.9",
46
+ ]
47
+
48
+ optional-dependencies.dev = [
49
+ "pytest>=8",
50
+ "pytest-cov>=4.0.0",
51
+ "pytest-xdist>=3.5.0",
52
+ "ruff>=0.4.0",
53
+ "mypy>=1.5.0",
54
+ "pre-commit>=3.3.3",
55
+ ]
56
+ optional-dependencies.experiments = [
57
+ "matplotlib>=3.7.0",
58
+ "scipy>=1.10",
59
+ "torchvision",
60
+ "h5py",
61
+ "medmnist",
62
+ ]
63
+
64
+ urls.Homepage = "https://github.com/geometric-intelligence/bispectrum"
65
+ urls.Repository = "https://github.com/geometric-intelligence/bispectrum"
66
+ urls.Issues = "https://github.com/geometric-intelligence/bispectrum/issues"
67
+
68
+ # Pin torch and torchvision to the cu128 wheels so they match systems with
69
+ # NVIDIA driver >= 12.8 (e.g. the local 8x H100 box). PyPI's default torch
70
+ # wheels target a newer CUDA runtime and crash with
71
+ # "NVIDIA driver on your system is too old (found version 12080)".
72
+ [[tool.uv.index]]
73
+ name = "pytorch-cu128"
74
+ url = "https://download.pytorch.org/whl/cu128"
75
+ explicit = true
76
+
77
+ [tool.uv.sources]
78
+ torch = { index = "pytorch-cu128" }
79
+ torchvision = { index = "pytorch-cu128" }
80
+
81
+ [tool.ruff]
82
+ target-version = "py312"
83
+ line-length = 120
84
+ src = ["src"]
85
+
86
+ [tool.ruff.lint]
87
+ select = ["E", "W", "F", "I", "B", "C4", "UP"]
88
+ ignore = ["E501", "B008", "C901", "E741"]
89
+
90
+ [tool.ruff.lint.pydocstyle]
91
+ convention = "google"
92
+
93
+ [tool.ruff.format]
94
+ quote-style = "single"
95
+ indent-style = "space"
96
+ skip-magic-trailing-comma = false
97
+ line-ending = "auto"
98
+
99
+ [tool.pytest.ini_options]
100
+ testpaths = ["tests"]
101
+
102
+ [tool.mypy]
103
+ python_version = "3.12"
104
+ strict = true
105
+
106
+ [tool.coverage.run]
107
+ source = ["src/bispectrum"]
108
+
109
+ [tool.coverage.report]
110
+ exclude_lines = [
111
+ "pragma: no cover",
112
+ "if TYPE_CHECKING:",
113
+ "raise NotImplementedError",
114
+ ]
@@ -0,0 +1,30 @@
1
+ """Bispectrum analysis for machine learning."""
2
+
3
+ from importlib.metadata import PackageNotFoundError
4
+ from importlib.metadata import version as _pkg_version
5
+
6
+ try:
7
+ __version__ = _pkg_version('bispectrum')
8
+ except PackageNotFoundError:
9
+ __version__ = '0.0.0+unknown'
10
+
11
+ from bispectrum.cn_on_cn import CnonCn
12
+ from bispectrum.dn_on_dn import DnonDn
13
+ from bispectrum.octa_on_octa import OctaonOcta
14
+ from bispectrum.rotation import random_rotation_matrix, rotate_spherical_function
15
+ from bispectrum.so2_on_disk import SO2onDisk
16
+ from bispectrum.so2_on_s1 import SO2onS1
17
+ from bispectrum.so3_on_s2 import SO3onS2
18
+ from bispectrum.torus_on_torus import TorusOnTorus
19
+
20
+ __all__ = [
21
+ 'CnonCn',
22
+ 'DnonDn',
23
+ 'OctaonOcta',
24
+ 'SO2onDisk',
25
+ 'SO2onS1',
26
+ 'SO3onS2',
27
+ 'TorusOnTorus',
28
+ 'random_rotation_matrix',
29
+ 'rotate_spherical_function',
30
+ ]