spherical-harmonics-basis 0.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.
Files changed (53) hide show
  1. spherical_harmonics_basis-0.0.2/.flake8 +13 -0
  2. spherical_harmonics_basis-0.0.2/.github/workflows/quality-checks.yaml +38 -0
  3. spherical_harmonics_basis-0.0.2/.gitignore +246 -0
  4. spherical_harmonics_basis-0.0.2/LICENSE +201 -0
  5. spherical_harmonics_basis-0.0.2/Makefile +55 -0
  6. spherical_harmonics_basis-0.0.2/PKG-INFO +134 -0
  7. spherical_harmonics_basis-0.0.2/README.md +123 -0
  8. spherical_harmonics_basis-0.0.2/dev_requirements.txt +13 -0
  9. spherical_harmonics_basis-0.0.2/pyproject.toml +39 -0
  10. spherical_harmonics_basis-0.0.2/requirements.txt +4 -0
  11. spherical_harmonics_basis-0.0.2/setup.py +32 -0
  12. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/__init__.py +19 -0
  13. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/fundamental_set.py +283 -0
  14. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/fundamental_system/__init__.py +0 -0
  15. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/fundamental_system/fs_10D.npz +0 -0
  16. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/fundamental_system/fs_11D.npz +0 -0
  17. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/fundamental_system/fs_12D.npz +0 -0
  18. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/fundamental_system/fs_13D.npz +0 -0
  19. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/fundamental_system/fs_14D.npz +0 -0
  20. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/fundamental_system/fs_15D.npz +0 -0
  21. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/fundamental_system/fs_16D.npz +0 -0
  22. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/fundamental_system/fs_17D.npz +0 -0
  23. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/fundamental_system/fs_18D.npz +0 -0
  24. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/fundamental_system/fs_19D.npz +0 -0
  25. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/fundamental_system/fs_20D.npz +0 -0
  26. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/fundamental_system/fs_3D.npz +0 -0
  27. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/fundamental_system/fs_4D.npz +0 -0
  28. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/fundamental_system/fs_5D.npz +0 -0
  29. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/fundamental_system/fs_6D.npz +0 -0
  30. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/fundamental_system/fs_7D.npz +0 -0
  31. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/fundamental_system/fs_8D.npz +0 -0
  32. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/fundamental_system/fs_9D.npz +0 -0
  33. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/gegenbauer_polynomial.py +178 -0
  34. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/jax.py +3 -0
  35. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/lab_extras/__init__.py +4 -0
  36. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/lab_extras/extras.py +27 -0
  37. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/lab_extras/jax/__init__.py +1 -0
  38. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/lab_extras/jax/extras.py +29 -0
  39. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/lab_extras/numpy/__init__.py +1 -0
  40. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/lab_extras/numpy/extras.py +29 -0
  41. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/lab_extras/tensorflow/__init__.py +1 -0
  42. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/lab_extras/tensorflow/extras.py +30 -0
  43. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/lab_extras/torch/__init__.py +1 -0
  44. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/lab_extras/torch/extras.py +35 -0
  45. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/plotting.py +188 -0
  46. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/spherical_harmonics.py +257 -0
  47. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/tensorflow.py +3 -0
  48. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/torch.py +3 -0
  49. spherical_harmonics_basis-0.0.2/src/spherical_harmonics/utils.py +90 -0
  50. spherical_harmonics_basis-0.0.2/tests/test_fundamental_set.py +99 -0
  51. spherical_harmonics_basis-0.0.2/tests/test_gegenbauer_polynomial.py +101 -0
  52. spherical_harmonics_basis-0.0.2/tests/test_plotting.py +42 -0
  53. spherical_harmonics_basis-0.0.2/tests/test_spherical_harmonics.py +229 -0
@@ -0,0 +1,13 @@
1
+ [flake8]
2
+ max-line-length = 88
3
+ select = C,E,F,W,B,B9
4
+ # ignore:
5
+ # E226 missing whitespace around arithmetic operator
6
+ # W503 Line break occurred before a binary operator
7
+ # W504 line break after binary operator
8
+ # F811 redefinition because of multiple dispatch
9
+ # E731 do not assign a lambda expression, use a def
10
+ ignore = E203, E501, W503, E226, W503, W504, F811, E731
11
+ max-complexity = 10
12
+ exclude = __init__.py,.git,__pycache__,.mypy_cache,.pytest_cache
13
+ per-file-ignores = **/__init__.py:F401,F403
@@ -0,0 +1,38 @@
1
+ name: QualityChecks
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ check-and-test:
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ matrix:
10
+ python-version: ["3.8", "3.9", "3.10", "3.11"]
11
+ fail-fast: false
12
+
13
+ name: Python-${{ matrix.python-version }}
14
+ steps:
15
+ #----------------------------------------------
16
+ # check-out repo and set-up python
17
+ #----------------------------------------------
18
+ - uses: actions/checkout@v2
19
+ - uses: actions/setup-python@v2
20
+ with:
21
+ python-version: ${{ matrix.python-version }}
22
+ #----------------------------------------------
23
+ # install
24
+ #----------------------------------------------
25
+ - name: Install dependencies
26
+ run: |
27
+ export LAB_NO_BUILD=1
28
+ make install
29
+ #----------------------------------------------
30
+ # Linting, formatting, etc (black, isort, flake and mypy)
31
+ #----------------------------------------------
32
+ - name: Run lint
33
+ run: make check
34
+ #----------------------------------------------
35
+ # Tests
36
+ #----------------------------------------------
37
+ - name: Run tests
38
+ run: make test
@@ -0,0 +1,246 @@
1
+ # Python
2
+ # Byte-compiled / optimized / DLL files
3
+ __pycache__/
4
+ *.py[cod]
5
+ *$py.class
6
+
7
+ # C extensions
8
+ *.so
9
+
10
+ # Distribution / packaging
11
+ .Python
12
+ build/
13
+ develop-eggs/
14
+ dist/
15
+ downloads/
16
+ eggs/
17
+ .eggs/
18
+ lib/
19
+ lib64/
20
+ parts/
21
+ sdist/
22
+ var/
23
+ wheels/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ cover/
54
+
55
+ # Translations
56
+ *.mo
57
+ *.pot
58
+
59
+ # Django stuff:
60
+ *.log
61
+ local_settings.py
62
+ db.sqlite3
63
+ db.sqlite3-journal
64
+
65
+ # Flask stuff:
66
+ instance/
67
+ .webassets-cache
68
+
69
+ # Scrapy stuff:
70
+ .scrapy
71
+
72
+ # Sphinx documentation
73
+ docs/_build/
74
+
75
+ # PyBuilder
76
+ .pybuilder/
77
+ target/
78
+
79
+ # Jupyter Notebook
80
+ .ipynb_checkpoints
81
+
82
+ # IPython
83
+ profile_default/
84
+ ipython_config.py
85
+
86
+ # pyenv
87
+ # For a library or package, you might want to ignore these files since the code is
88
+ # intended to run in multiple environments; otherwise, check them in:
89
+ # .python-version
90
+
91
+ # pipenv
92
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
94
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
95
+ # install all needed dependencies.
96
+ #Pipfile.lock
97
+
98
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
99
+ __pypackages__/
100
+
101
+ # Celery stuff
102
+ celerybeat-schedule
103
+ celerybeat.pid
104
+
105
+ # SageMath parsed files
106
+ *.sage.py
107
+
108
+ # Environments
109
+ .env
110
+ .venv
111
+ env/
112
+ venv/
113
+ ENV/
114
+ env.bak/
115
+ venv.bak/
116
+
117
+ # Spyder project settings
118
+ .spyderproject
119
+ .spyproject
120
+
121
+ # Rope project settings
122
+ .ropeproject
123
+
124
+ # mkdocs documentation
125
+ /site
126
+
127
+ # mypy
128
+ .mypy_cache/
129
+ .dmypy.json
130
+ dmypy.json
131
+
132
+ # Pyre type checker
133
+ .pyre/
134
+
135
+ # pytype static type analyzer
136
+ .pytype/
137
+
138
+ # Cython debug symbols
139
+ cython_debug/
140
+
141
+
142
+ # Pycharm
143
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
144
+ # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
145
+
146
+ # User-specific stuff
147
+ .idea/**/workspace.xml
148
+ .idea/**/tasks.xml
149
+ .idea/**/usage.statistics.xml
150
+ .idea/**/dictionaries
151
+ .idea/**/shelf
152
+
153
+ # Generated files
154
+ .idea/**/contentModel.xml
155
+
156
+ # Sensitive or high-churn files
157
+ .idea/**/dataSources/
158
+ .idea/**/dataSources.ids
159
+ .idea/**/dataSources.local.xml
160
+ .idea/**/sqlDataSources.xml
161
+ .idea/**/dynamic.xml
162
+ .idea/**/uiDesigner.xml
163
+ .idea/**/dbnavigator.xml
164
+
165
+ # Gradle
166
+ .idea/**/gradle.xml
167
+ .idea/**/libraries
168
+
169
+ # Gradle and Maven with auto-import
170
+ # When using Gradle or Maven with auto-import, you should exclude module files,
171
+ # since they will be recreated, and may cause churn. Uncomment if using
172
+ # auto-import.
173
+ # .idea/artifacts
174
+ # .idea/compiler.xml
175
+ # .idea/jarRepositories.xml
176
+ # .idea/modules.xml
177
+ # .idea/*.iml
178
+ # .idea/modules
179
+ # *.iml
180
+ # *.ipr
181
+
182
+ # CMake
183
+ cmake-build-*/
184
+
185
+ # Mongo Explorer plugin
186
+ .idea/**/mongoSettings.xml
187
+
188
+ # File-based project format
189
+ *.iws
190
+
191
+ # IntelliJ
192
+ out/
193
+
194
+ # mpeltonen/sbt-idea plugin
195
+ .idea_modules/
196
+
197
+ # JIRA plugin
198
+ atlassian-ide-plugin.xml
199
+
200
+ # Cursive Clojure plugin
201
+ .idea/replstate.xml
202
+
203
+ # Crashlytics plugin (for Android Studio and IntelliJ)
204
+ com_crashlytics_export_strings.xml
205
+ crashlytics.properties
206
+ crashlytics-build.properties
207
+ fabric.properties
208
+
209
+ # Editor-based Rest Client
210
+ .idea/httpRequests
211
+
212
+ # Android studio 3.1+ serialized cache file
213
+ .idea/caches/build_file_checksums.ser
214
+
215
+ # Configuration
216
+ .idea/
217
+
218
+
219
+ # macOS
220
+ # General
221
+ .DS_Store
222
+ .AppleDouble
223
+ .LSOverride
224
+
225
+ # Icon must end with two \r
226
+ Icon
227
+
228
+
229
+ # Thumbnails
230
+ ._*
231
+
232
+ # Files that might appear in the root of a volume
233
+ .DocumentRevisions-V100
234
+ .fseventsd
235
+ .Spotlight-V100
236
+ .TemporaryItems
237
+ .Trashes
238
+ .VolumeIcon.icns
239
+ .com.apple.timemachine.donotpresent
240
+
241
+ # Directories potentially created on remote AFP share
242
+ .AppleDB
243
+ .AppleDesktop
244
+ Network Trash Folder
245
+ Temporary Items
246
+ .apdisk
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,55 @@
1
+ .PHONY: help install docs format check test check-and-test
2
+
3
+
4
+ LIB_NAME = spherical_harmonics
5
+ TESTS_NAME = tests
6
+ LINT_NAMES = src/$(LIB_NAME) $(TESTS_NAME)
7
+ TYPE_NAMES = src/$(LIB_NAME)
8
+ SUCCESS='\033[0;32m'
9
+ UNAME_S = $(shell uname -s)
10
+
11
+ # the --per-file-ignores are to ignore "unused import" warnings in __init__.py files (F401)
12
+ # the F403 ignore in gpflux/__init__.py allows the `from .<submodule> import *`
13
+ LINT_FILE_IGNORES = "src/$(LIB_NAME)/__init__.py:F401,F403"
14
+
15
+
16
+ help: ## Shows this help message
17
+ # $(MAKEFILE_LIST) is set by make itself; the following parses the `target: ## help line` format and adds color highlighting
18
+ @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-24s\033[0m %s\n", $$1, $$2}'
19
+
20
+
21
+ install: ## Install repo for developement
22
+ @echo "\n=== pip install package with requirements =============="
23
+ LAB_NO_BUILD=1 pip install backends
24
+ @echo "\n=== pip install dev requirements ======================"
25
+ pip install -r requirements.txt
26
+ @echo "\n=== pip install test requirements ======================"
27
+ pip install -r dev_requirements.txt
28
+ pip install -e .
29
+
30
+
31
+ format: ## Formats code with `black` and `isort`
32
+ @echo "\n=== Autoflake =============================================="
33
+ autoflake --remove-all-unused-imports --recursive \
34
+ --remove-unused-variables --in-place --exclude=__init__.py \
35
+ $(LINT_NAMES)
36
+ @echo "\n=== black =============================================="
37
+ black $(LINT_NAMES)
38
+ @echo "\n=== isort =============================================="
39
+ isort $(LINT_NAMES)
40
+
41
+
42
+ check: ## Runs all static checks such as code formatting checks, linting, mypy
43
+ @echo "\n=== flake8 (linting)===================================="
44
+ flake8 --statistics --exclude=.ipynb_checkpoints
45
+ @echo "\n=== black (formatting) ================================="
46
+ black --check --diff $(LINT_NAMES)
47
+ @echo "\n=== isort (formatting) ================================="
48
+ isort --check --diff $(LINT_NAMES)
49
+ @echo "\n=== mypy (static type checking) ========================"
50
+ mypy $(TYPE_NAMES)
51
+
52
+ test: ## Run unit and integration tests with pytest
53
+ pytest -v --tb=short --durations=10 $(TESTS_NAME)
54
+
55
+ check-and-test: check test ## Run pytest and static tests
@@ -0,0 +1,134 @@
1
+ Metadata-Version: 2.1
2
+ Name: spherical-harmonics-basis
3
+ Version: 0.0.2
4
+ Summary: Python Implementation of Spherical harmonics in dimension >= 3
5
+ Author-email: Vincent Dutordoir <vd309@cam.ac.uk>
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: numpy
8
+ Requires-Dist: scipy
9
+ Project-URL: Source, https://github.com/vdutor/SphericalHarmonics
10
+
11
+ # Spherical Harmonics
12
+
13
+ This package implements spherical harmonics in d-dimensions in Python. The spherical harmonics are defined as zonal functions through the Gegenbauer polynomials and a fundamental system of points (see [Dai and Xu (2013)](https://arxiv.org/pdf/1304.2585.pdf), defintion 3.1). The spherical harmonics form a ortho-normal set on the hypersphere. This package implements a greedy algorithm to compute the fundamental set for dimensions up to 20.
14
+
15
+ The computations of this package can be carried out in either TensorFlow, Pytorch, Jax or NumPy.
16
+ A specific backend can be chosen by simply importing it as follows
17
+ ```
18
+ import spherical_harmonics.tensorflow # noqa
19
+ ```
20
+
21
+ ## Example
22
+
23
+ ### 3 Dimensional
24
+ ```python
25
+ import tensorflow as tf
26
+ import spherical_harmonics.tensorflow # run computation in TensorFlow
27
+
28
+ from spherical_harmonics import SphericalHarmonics
29
+ from spherical_harmonics.utils import l2norm
30
+
31
+ dimension = 3
32
+ max_degree = 10
33
+ # Returns all the spherical harmonics in dimension 3 up to degree 10.
34
+ Phi = SphericalHarmonics(dimension, max_degree)
35
+
36
+ x = tf.random.normal((101, dimension)) # Create random points to evaluate Phi
37
+ x = x / tf.norm(x, axis=1, keepdims=True) # Normalize vectors
38
+ out = Phi(x) # Evaluate spherical harmonics at `x`
39
+
40
+ # In 3D there are (2 * degree + 1) spherical harmonics per degree,
41
+ # so in total we have 400 spherical harmonics of degree 20 and smaller.
42
+ num_harmonics = 0
43
+ for degree in range(max_degree):
44
+ num_harmonics += 2 * degree + 1
45
+ assert num_harmonics == 100
46
+
47
+ assert out.shape == (101, num_harmonics)
48
+ ```
49
+
50
+ ### 4 Dimensional
51
+
52
+ The setup for 4 dimensional spherical harmonics is very similar to the 3D case. Note that there are more spherical harmonics now of degree smaller than 20.
53
+
54
+ ```python
55
+ import numpy as np
56
+ from spherical_harmonics import SphericalHarmonics
57
+ from spherical_harmonics.utils import l2norm
58
+
59
+ dimension = 4
60
+ max_degree = 10
61
+ # Returns all the spherical harmonics of degree 4 up to degree 10.
62
+ Phi = SphericalHarmonics(dimension, max_degree)
63
+
64
+ x = np.random.randn(101, dimension) # Create random points to evaluation Phi
65
+ x = x / l2norm(x) # normalize vectors
66
+ out = Phi(x) # Evaluate spherical harmonics at `x`
67
+
68
+ # In 4D there are (degree + 1)**2 spherical harmonics per degree,
69
+ # so in total we have 385 spherical harmonics of degree 20 and smaller.
70
+ num_harmonics = 0
71
+ for degree in range(max_degree):
72
+ num_harmonics += (degree + 1) ** 2
73
+ assert num_harmonics == 385
74
+
75
+ assert out.shape == (101, num_harmonics)
76
+ ```
77
+
78
+ ---
79
+ **NOTE**
80
+
81
+ The fundamental systems up to dimensions 20 are precomputed and stored in `spherical_harmonics/fundamental_system`. For each dimension we precompute the first amount of spherical harmonics. This means that in each dimension we support a varying number of maximum degree (`max_degree`) and number of spherical harmonics:
82
+
83
+ | Dimension | Max Degree | Number Harmonics |
84
+ |----------:|-----------:|-----------------:|
85
+ | 3 | 34 | 1156 |
86
+ | 4 | 20 | 2870 |
87
+ | 5 | 10 | 16170 |
88
+ | 6 | 8 | 1254 |
89
+ | 7 | 7 | 1386 |
90
+ | 8 | 6 | 1122 |
91
+ | 9 | 6 | 1782 |
92
+ | 10 | 6 | 2717 |
93
+ | 11 | 5 | 1287 |
94
+ | 12 | 5 | 1729 |
95
+ | 13 | 5 | 2275 |
96
+ | 14 | 5 | 2940 |
97
+ | 15 | 5 | 3740 |
98
+ | 16 | 4 | 952 |
99
+ | 17 | 4 | 1122 |
100
+ | 18 | 4 | 1311 |
101
+ | 19 | 4 | 1520 |
102
+ | 20 | 4 | 1750 |
103
+
104
+ To precompute a larger fundamental system for a dimension run the following script
105
+ ```
106
+ cd spherical_harmonics
107
+ python fundament_set.py
108
+ ```
109
+ after specifying the desired options in the file.
110
+
111
+ ---
112
+
113
+ ## Installation
114
+
115
+ The package is now available on PyPI under the name of `spherical-harmonics-basis`.
116
+
117
+ Simply run
118
+ ```
119
+ pip install spherical-harmonics-basis
120
+ ```
121
+
122
+
123
+ ## Citation
124
+
125
+ If this code was useful for your research, please consider citing the following [paper](http://proceedings.mlr.press/v119/dutordoir20a/dutordoir20a.pdf):
126
+ ```
127
+ @inproceedings{Dutordoir2020spherical,
128
+ title = {{Sparse Gaussian Processes with Spherical Harmonic Features}},
129
+ author = {Dutordoir, Vincent and Durrande, Nicolas and Hensman, James},
130
+ booktitle = {Proceedings of the 37th International Conference on Machine Learning (ICML)},
131
+ date = {2020},
132
+ }
133
+ ```
134
+