saiunit 0.0.17__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 (136) hide show
  1. saiunit-0.0.17/LICENSE +202 -0
  2. saiunit-0.0.17/PKG-INFO +196 -0
  3. saiunit-0.0.17/README.md +153 -0
  4. saiunit-0.0.17/brainunit/brainunit/__init__.py +65 -0
  5. saiunit-0.0.17/brainunit/brainunit/_base.py +20 -0
  6. saiunit-0.0.17/brainunit/brainunit/_celsius.py +20 -0
  7. saiunit-0.0.17/brainunit/brainunit/_unit_common.py +19 -0
  8. saiunit-0.0.17/brainunit/brainunit/_unit_constants.py +20 -0
  9. saiunit-0.0.17/brainunit/brainunit/_unit_shortcuts.py +20 -0
  10. saiunit-0.0.17/brainunit/brainunit/autograd/__init__.py +30 -0
  11. saiunit-0.0.17/brainunit/brainunit/autograd/_hessian.py +19 -0
  12. saiunit-0.0.17/brainunit/brainunit/autograd/_jacobian.py +19 -0
  13. saiunit-0.0.17/brainunit/brainunit/autograd/_value_and_grad.py +19 -0
  14. saiunit-0.0.17/brainunit/brainunit/autograd/_vector_grad.py +19 -0
  15. saiunit-0.0.17/brainunit/brainunit/constants.py +20 -0
  16. saiunit-0.0.17/brainunit/brainunit/fft/__init__.py +25 -0
  17. saiunit-0.0.17/brainunit/brainunit/fft/_fft_change_unit.py +19 -0
  18. saiunit-0.0.17/brainunit/brainunit/fft/_fft_keep_unit.py +20 -0
  19. saiunit-0.0.17/brainunit/brainunit/lax/__init__.py +45 -0
  20. saiunit-0.0.17/brainunit/brainunit/lax/_lax_accept_unitless.py +19 -0
  21. saiunit-0.0.17/brainunit/brainunit/lax/_lax_array_creation.py +19 -0
  22. saiunit-0.0.17/brainunit/brainunit/lax/_lax_change_unit.py +20 -0
  23. saiunit-0.0.17/brainunit/brainunit/lax/_lax_keep_unit.py +20 -0
  24. saiunit-0.0.17/brainunit/brainunit/lax/_lax_linalg.py +20 -0
  25. saiunit-0.0.17/brainunit/brainunit/lax/_lax_remove_unit.py +20 -0
  26. saiunit-0.0.17/brainunit/brainunit/lax/_misc.py +20 -0
  27. saiunit-0.0.17/brainunit/brainunit/linalg/__init__.py +25 -0
  28. saiunit-0.0.17/brainunit/brainunit/linalg/_linalg_change_unit.py +19 -0
  29. saiunit-0.0.17/brainunit/brainunit/linalg/_linalg_keep_unit.py +19 -0
  30. saiunit-0.0.17/brainunit/brainunit/linalg/_linalg_remove_unit.py +20 -0
  31. saiunit-0.0.17/brainunit/brainunit/math/__init__.py +61 -0
  32. saiunit-0.0.17/brainunit/brainunit/math/_activation.py +20 -0
  33. saiunit-0.0.17/brainunit/brainunit/math/_alias.py +20 -0
  34. saiunit-0.0.17/brainunit/brainunit/math/_einops.py +20 -0
  35. saiunit-0.0.17/brainunit/brainunit/math/_fun_accept_unitless.py +20 -0
  36. saiunit-0.0.17/brainunit/brainunit/math/_fun_array_creation.py +20 -0
  37. saiunit-0.0.17/brainunit/brainunit/math/_fun_change_unit.py +20 -0
  38. saiunit-0.0.17/brainunit/brainunit/math/_fun_keep_unit.py +20 -0
  39. saiunit-0.0.17/brainunit/brainunit/math/_fun_remove_unit.py +20 -0
  40. saiunit-0.0.17/brainunit/brainunit/math/_misc.py +20 -0
  41. saiunit-0.0.17/brainunit/brainunit/math/fft.py +20 -0
  42. saiunit-0.0.17/brainunit/brainunit/math/linalg.py +20 -0
  43. saiunit-0.0.17/brainunit/brainunit/sparse/__init__.py +22 -0
  44. saiunit-0.0.17/brainunit/brainunit/sparse/_block_csr.py +20 -0
  45. saiunit-0.0.17/brainunit/brainunit/sparse/_block_ell.py +20 -0
  46. saiunit-0.0.17/brainunit/brainunit/sparse/_coo.py +20 -0
  47. saiunit-0.0.17/brainunit/brainunit/sparse/_csr.py +20 -0
  48. saiunit-0.0.17/pyproject.toml +69 -0
  49. saiunit-0.0.17/saiunit/__init__.py +61 -0
  50. saiunit-0.0.17/saiunit/_base.py +5416 -0
  51. saiunit-0.0.17/saiunit/_base_test.py +1775 -0
  52. saiunit-0.0.17/saiunit/_celsius.py +87 -0
  53. saiunit-0.0.17/saiunit/_celsius_test.py +33 -0
  54. saiunit-0.0.17/saiunit/_compatible_import.py +68 -0
  55. saiunit-0.0.17/saiunit/_matplotlib_compat.py +51 -0
  56. saiunit-0.0.17/saiunit/_matplotlib_compat_test.py +66 -0
  57. saiunit-0.0.17/saiunit/_misc.py +49 -0
  58. saiunit-0.0.17/saiunit/_sparse_base.py +167 -0
  59. saiunit-0.0.17/saiunit/_unit_common.py +7926 -0
  60. saiunit-0.0.17/saiunit/_unit_constants.py +163 -0
  61. saiunit-0.0.17/saiunit/_unit_shortcuts.py +121 -0
  62. saiunit-0.0.17/saiunit/autograd/__init__.py +30 -0
  63. saiunit-0.0.17/saiunit/autograd/_hessian.py +109 -0
  64. saiunit-0.0.17/saiunit/autograd/_hessian_test.py +123 -0
  65. saiunit-0.0.17/saiunit/autograd/_jacobian.py +424 -0
  66. saiunit-0.0.17/saiunit/autograd/_jacobian_test.py +170 -0
  67. saiunit-0.0.17/saiunit/autograd/_misc.py +54 -0
  68. saiunit-0.0.17/saiunit/autograd/_value_and_grad.py +161 -0
  69. saiunit-0.0.17/saiunit/autograd/_value_and_grad_test.py +110 -0
  70. saiunit-0.0.17/saiunit/autograd/_vector_grad.py +110 -0
  71. saiunit-0.0.17/saiunit/autograd/_vector_grad_test.py +86 -0
  72. saiunit-0.0.17/saiunit/constants.py +188 -0
  73. saiunit-0.0.17/saiunit/constants_test.py +87 -0
  74. saiunit-0.0.17/saiunit/fft/__init__.py +25 -0
  75. saiunit-0.0.17/saiunit/fft/_fft_change_unit.py +1238 -0
  76. saiunit-0.0.17/saiunit/fft/_fft_change_unit_test.py +179 -0
  77. saiunit-0.0.17/saiunit/fft/_fft_keep_unit.py +118 -0
  78. saiunit-0.0.17/saiunit/fft/_fft_keep_unit_test.py +60 -0
  79. saiunit-0.0.17/saiunit/lax/__init__.py +45 -0
  80. saiunit-0.0.17/saiunit/lax/_lax_accept_unitless.py +382 -0
  81. saiunit-0.0.17/saiunit/lax/_lax_accept_unitless_test.py +194 -0
  82. saiunit-0.0.17/saiunit/lax/_lax_array_creation.py +88 -0
  83. saiunit-0.0.17/saiunit/lax/_lax_array_creation_test.py +97 -0
  84. saiunit-0.0.17/saiunit/lax/_lax_change_unit.py +315 -0
  85. saiunit-0.0.17/saiunit/lax/_lax_change_unit_test.py +289 -0
  86. saiunit-0.0.17/saiunit/lax/_lax_keep_unit.py +1485 -0
  87. saiunit-0.0.17/saiunit/lax/_lax_keep_unit_test.py +828 -0
  88. saiunit-0.0.17/saiunit/lax/_lax_linalg.py +531 -0
  89. saiunit-0.0.17/saiunit/lax/_lax_linalg_test.py +255 -0
  90. saiunit-0.0.17/saiunit/lax/_lax_remove_unit.py +108 -0
  91. saiunit-0.0.17/saiunit/lax/_lax_remove_unit_test.py +88 -0
  92. saiunit-0.0.17/saiunit/lax/_misc.py +87 -0
  93. saiunit-0.0.17/saiunit/lax/_misc_test.py +67 -0
  94. saiunit-0.0.17/saiunit/linalg/__init__.py +29 -0
  95. saiunit-0.0.17/saiunit/linalg/_linalg_change_unit.py +410 -0
  96. saiunit-0.0.17/saiunit/linalg/_linalg_change_unit_test.py +131 -0
  97. saiunit-0.0.17/saiunit/linalg/_linalg_keep_unit.py +509 -0
  98. saiunit-0.0.17/saiunit/linalg/_linalg_keep_unit_test.py +48 -0
  99. saiunit-0.0.17/saiunit/linalg/_linalg_remove_unit.py +161 -0
  100. saiunit-0.0.17/saiunit/math/__init__.py +61 -0
  101. saiunit-0.0.17/saiunit/math/_activation.py +536 -0
  102. saiunit-0.0.17/saiunit/math/_alias.py +41 -0
  103. saiunit-0.0.17/saiunit/math/_einops.py +1246 -0
  104. saiunit-0.0.17/saiunit/math/_einops_parsing.py +170 -0
  105. saiunit-0.0.17/saiunit/math/_einops_parsing_test.py +126 -0
  106. saiunit-0.0.17/saiunit/math/_einops_test.py +502 -0
  107. saiunit-0.0.17/saiunit/math/_fun_accept_unitless.py +1270 -0
  108. saiunit-0.0.17/saiunit/math/_fun_accept_unitless_test.py +199 -0
  109. saiunit-0.0.17/saiunit/math/_fun_array_creation.py +1033 -0
  110. saiunit-0.0.17/saiunit/math/_fun_array_creation_test.py +362 -0
  111. saiunit-0.0.17/saiunit/math/_fun_change_unit.py +1382 -0
  112. saiunit-0.0.17/saiunit/math/_fun_change_unit_test.py +160 -0
  113. saiunit-0.0.17/saiunit/math/_fun_keep_unit.py +3535 -0
  114. saiunit-0.0.17/saiunit/math/_fun_keep_unit_test.py +818 -0
  115. saiunit-0.0.17/saiunit/math/_fun_remove_unit.py +1299 -0
  116. saiunit-0.0.17/saiunit/math/_fun_remove_unit_test.py +370 -0
  117. saiunit-0.0.17/saiunit/math/_misc.py +476 -0
  118. saiunit-0.0.17/saiunit/math/_misc_test.py +59 -0
  119. saiunit-0.0.17/saiunit/math/fft.py +18 -0
  120. saiunit-0.0.17/saiunit/math/linalg.py +19 -0
  121. saiunit-0.0.17/saiunit/sparse/__init__.py +26 -0
  122. saiunit-0.0.17/saiunit/sparse/_block_csr.py +240 -0
  123. saiunit-0.0.17/saiunit/sparse/_block_csr_benchmark.py +99 -0
  124. saiunit-0.0.17/saiunit/sparse/_block_ell.py +251 -0
  125. saiunit-0.0.17/saiunit/sparse/_block_ell_benchmark.py +99 -0
  126. saiunit-0.0.17/saiunit/sparse/_coo.py +599 -0
  127. saiunit-0.0.17/saiunit/sparse/_coo_test.py +322 -0
  128. saiunit-0.0.17/saiunit/sparse/_csr.py +686 -0
  129. saiunit-0.0.17/saiunit/sparse/_csr_test.py +643 -0
  130. saiunit-0.0.17/saiunit.egg-info/PKG-INFO +196 -0
  131. saiunit-0.0.17/saiunit.egg-info/SOURCES.txt +134 -0
  132. saiunit-0.0.17/saiunit.egg-info/dependency_links.txt +1 -0
  133. saiunit-0.0.17/saiunit.egg-info/requires.txt +16 -0
  134. saiunit-0.0.17/saiunit.egg-info/top_level.txt +2 -0
  135. saiunit-0.0.17/setup.cfg +4 -0
  136. saiunit-0.0.17/setup.py +39 -0
saiunit-0.0.17/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [2024] [BDP Ecosystem]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,196 @@
1
+ Metadata-Version: 2.4
2
+ Name: saiunit
3
+ Version: 0.0.17
4
+ Summary: Enabling Unit-aware Computations for AI-driven Scientific Computing.
5
+ Author-email: SAIUnit Developers <chao.brain@qq.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: homepage, https://github.com/chaobrain/saiunit
8
+ Project-URL: repository, https://github.com/chaobrain/saiunit
9
+ Project-URL: Bug Tracker, https://github.com/chaobrain/saiunit/issues
10
+ Project-URL: Documentation, https://saiunit.readthedocs.io/
11
+ Keywords: physical unit,physical quantity,brain modeling,scientific computing,AI for science
12
+ Classifier: Natural Language :: English
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: Programming Language :: Python
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
24
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
25
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
26
+ Classifier: Topic :: Software Development :: Libraries
27
+ Requires-Python: >=3.10
28
+ Description-Content-Type: text/markdown
29
+ License-File: LICENSE
30
+ Requires-Dist: jax
31
+ Requires-Dist: jaxlib
32
+ Requires-Dist: numpy
33
+ Requires-Dist: typing_extensions
34
+ Provides-Extra: testing
35
+ Requires-Dist: pytest; extra == "testing"
36
+ Provides-Extra: cpu
37
+ Requires-Dist: jax[cpu]; extra == "cpu"
38
+ Provides-Extra: cuda12
39
+ Requires-Dist: jax[cuda12]; extra == "cuda12"
40
+ Provides-Extra: tpu
41
+ Requires-Dist: jax[tpu]; extra == "tpu"
42
+ Dynamic: license-file
43
+
44
+ <p align="center">
45
+ <img alt="Header image of SAIUnit." src="https://raw.githubusercontent.com/chaobrain/saiunit/main/docs/_static/logo.png" width=80%>
46
+ </p>
47
+
48
+
49
+
50
+ <p align="center">
51
+ <a href="https://pypi.org/project/saiunit/"><img alt="Supported Python Version" src="https://img.shields.io/pypi/pyversions/saiunit"></a>
52
+ <a href="https://github.com/chaobrain/saiunit/blob/main/LICENSE"><img alt="LICENSE" src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"></a>
53
+ <a href='https://saiunit.readthedocs.io/?badge=latest'>
54
+ <img src='https://readthedocs.org/projects/saiunit/badge/?version=latest' alt='Documentation Status' />
55
+ </a>
56
+ <a href="https://badge.fury.io/py/saiunit"><img alt="PyPI version" src="https://badge.fury.io/py/saiunit.svg"></a>
57
+ <a href="https://github.com/chaobrain/saiunit/actions/workflows/CI.yml"><img alt="Continuous Integration" src="https://github.com/chaobrain/saiunit/actions/workflows/CI.yml/badge.svg"></a>
58
+ <a href="https://pepy.tech/projects/saiunit"><img src="https://static.pepy.tech/badge/saiunit" alt="PyPI Downloads"></a>
59
+ </p>
60
+
61
+
62
+ ## Motivation
63
+
64
+ [SAIUnit](https://github.com/chaobrain/saiunit) (/saɪ ˈjuːnɪt/) is designed to provide physical units and unit-aware mathematical systems tailored for **S**cientific **AI** within JAX. In this context, Scientific AI refers to the use of AI models or tools to advance scientific computations. SAIUnit evolves from our [BrainUnit](https://github.com/chaobrain/brainunit), a unit framework originally developed for brain dynamics modeling, extending its capabilities to support a broader range of scientific computing applications. SAIUnit is committed to providing rigorous and automatic physical unit conversion and analysis system for general AI-driven scientific computing.
65
+
66
+
67
+
68
+ ## Features
69
+
70
+ Compared to existing unit libraries, such as [Quantities](https://github.com/python-quantities/python-quantities) and [Pint](https://github.com/hgrecco/pint), SAIUnit introduces a rigorous physical unit system specifically designed to support AI computations (e.g., automatic differentiation, just-in-time compilation, and parallelization). Its unique advantages include:
71
+
72
+ - Integration of over 2,000 commonly used physical units and constants
73
+ - Implementation of more than 500 unit-aware mathematical functions
74
+ - Deep integration with JAX, providing comprehensive support for modern AI framework features including automatic differentiation (autograd), just-in-time compilation (JIT), vectorization, and parallel computation
75
+ - Unit conversion and analysis are performed at compilation time, resulting in zero runtime overhead
76
+ - Strict physical unit type checking and dimensional inference system, detecting unit inconsistencies during compilation
77
+
78
+
79
+ ```mermaid
80
+ graph TD
81
+ A[SAIUnit] --> B[Physical Units]
82
+ A --> C[Mathematical Functions]
83
+ A --> D[JAX Integration]
84
+ B --> B1[2000+ Units]
85
+ B --> B2[Physical Constants]
86
+ C --> C1[500+ Unit-aware Functions]
87
+ D --> D1[Autograd]
88
+ D --> D2[JIT Compilation]
89
+ D --> D3[Vectorization]
90
+ D --> D4[Parallelization]
91
+ ```
92
+
93
+ We hope these features establish SAIUnit as a reliable physical unit handling solution for general AI-driven scientific computing scenarios.
94
+
95
+ A quick example:
96
+
97
+ ```python
98
+
99
+ import saiunit as u
100
+
101
+ # Define a physical quantity
102
+ x = 3.0 * u.meter
103
+ x
104
+ # [out] 3. * meter
105
+
106
+ # autograd
107
+ f = lambda x: x ** 3
108
+ u.autograd.grad(f)(x)
109
+ # [out] 27. * meter2
110
+
111
+
112
+ # JIT
113
+ import jax
114
+ jax.jit(f)(x)
115
+ # [out] 27. * klitre
116
+
117
+ # vmap
118
+ jax.vmap(f)(u.math.arange(0. * u.mV, 10. * u.mV, 1. * u.mV))
119
+ # [out] ArrayImpl([ 0., 1., 8., 27., 64., 125., 216., 343., 512., 729.]) * mvolt3
120
+ ```
121
+
122
+
123
+
124
+ ## Installation
125
+
126
+ ``saiunit`` has been well tested on ``python>=3.9`` + ``jax>=0.4.30`` environments, and can be installed on Windows, Linux, and MacOS.
127
+
128
+ You can install ``saiunit`` via pip:
129
+
130
+ ```bash
131
+ pip install saiunit --upgrade
132
+ ```
133
+
134
+ which should install in about 1 minute. If you want to install the latest version from the source, you can clone the repository and install it:
135
+
136
+ ```bash
137
+ git clone https://github.com/chaobrain/saiunit.git
138
+ cd saiunit
139
+ pip install -e .
140
+ ```
141
+
142
+ Alternatively, you can install `BrainX`, which bundles `saiunit` with other compatible packages for a comprehensive brain modeling ecosystem:
143
+
144
+ ```bash
145
+ pip install BrainX -U
146
+ ```
147
+
148
+ ## Documentation
149
+
150
+ The official documentation is hosted on Read the Docs: [https://saiunit.readthedocs.io](https://saiunit.readthedocs.io)
151
+
152
+
153
+
154
+ ## Citation
155
+
156
+ ```bibtex
157
+ @article{wang2025integrating,
158
+ title={Integrating physical units into high-performance AI-driven scientific computing},
159
+ author={Wang, Chaoming and He, Sichao and Luo, Shouwei and Huan, Yuxiang and Wu, Si},
160
+ journal={Nature Communications},
161
+ volume={16},
162
+ number={1},
163
+ pages={3609},
164
+ year={2025},
165
+ publisher={Nature Publishing Group UK London},
166
+ url={https://doi.org/10.1038/s41467-025-58626-4}
167
+ }
168
+ ```
169
+
170
+
171
+ ## Ecosystem
172
+
173
+ `saiunit` has been deeply integrated into following diverse projects, such as:
174
+
175
+ - [``brainstate``](https://github.com/chaobrain/brainstate): A State-based Transformation System for Program Compilation and Augmentation
176
+ - [``braintaichi``](https://github.com/chaobrain/braintaichi): Leveraging Taichi Lang to customize brain dynamics operators
177
+ - [``braintools``](https://github.com/chaobrain/braintools): The Common Toolbox for Brain Dynamics Programming.
178
+ - [``dendritex``](https://github.com/chaobrain/dendritex): Dendritic Modeling in JAX
179
+ - [``pinnx``](https://github.com/chaobrain/pinnx): Physics-Informed Neural Networks for Scientific Machine Learning in JAX.
180
+
181
+
182
+ Other unofficial projects include:
183
+
184
+ - [``diffrax``](https://github.com/chaoming0625/diffrax): Numerical differential equation solvers in JAX.
185
+ - [``jax-md``](https://github.com/Routhleck/jax-md): Differentiable Molecular Dynamics in JAX
186
+ - [``Catalax``](https://github.com/Routhleck/Catalax): JAX-based framework to model biological systems
187
+ - ...
188
+
189
+
190
+ ## Acknowledgement
191
+
192
+ The initial version of the project benefited a lot from the following projects:
193
+
194
+ - [``astropy.units``](https://docs.astropy.org/en/stable/units/index.html): physical units in ``astropy``.
195
+ - [``brian2.units``](https://brian2.readthedocs.io/en/stable/user/units.html): physical units in ``brian2``.
196
+
@@ -0,0 +1,153 @@
1
+ <p align="center">
2
+ <img alt="Header image of SAIUnit." src="https://raw.githubusercontent.com/chaobrain/saiunit/main/docs/_static/logo.png" width=80%>
3
+ </p>
4
+
5
+
6
+
7
+ <p align="center">
8
+ <a href="https://pypi.org/project/saiunit/"><img alt="Supported Python Version" src="https://img.shields.io/pypi/pyversions/saiunit"></a>
9
+ <a href="https://github.com/chaobrain/saiunit/blob/main/LICENSE"><img alt="LICENSE" src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"></a>
10
+ <a href='https://saiunit.readthedocs.io/?badge=latest'>
11
+ <img src='https://readthedocs.org/projects/saiunit/badge/?version=latest' alt='Documentation Status' />
12
+ </a>
13
+ <a href="https://badge.fury.io/py/saiunit"><img alt="PyPI version" src="https://badge.fury.io/py/saiunit.svg"></a>
14
+ <a href="https://github.com/chaobrain/saiunit/actions/workflows/CI.yml"><img alt="Continuous Integration" src="https://github.com/chaobrain/saiunit/actions/workflows/CI.yml/badge.svg"></a>
15
+ <a href="https://pepy.tech/projects/saiunit"><img src="https://static.pepy.tech/badge/saiunit" alt="PyPI Downloads"></a>
16
+ </p>
17
+
18
+
19
+ ## Motivation
20
+
21
+ [SAIUnit](https://github.com/chaobrain/saiunit) (/saɪ ˈjuːnɪt/) is designed to provide physical units and unit-aware mathematical systems tailored for **S**cientific **AI** within JAX. In this context, Scientific AI refers to the use of AI models or tools to advance scientific computations. SAIUnit evolves from our [BrainUnit](https://github.com/chaobrain/brainunit), a unit framework originally developed for brain dynamics modeling, extending its capabilities to support a broader range of scientific computing applications. SAIUnit is committed to providing rigorous and automatic physical unit conversion and analysis system for general AI-driven scientific computing.
22
+
23
+
24
+
25
+ ## Features
26
+
27
+ Compared to existing unit libraries, such as [Quantities](https://github.com/python-quantities/python-quantities) and [Pint](https://github.com/hgrecco/pint), SAIUnit introduces a rigorous physical unit system specifically designed to support AI computations (e.g., automatic differentiation, just-in-time compilation, and parallelization). Its unique advantages include:
28
+
29
+ - Integration of over 2,000 commonly used physical units and constants
30
+ - Implementation of more than 500 unit-aware mathematical functions
31
+ - Deep integration with JAX, providing comprehensive support for modern AI framework features including automatic differentiation (autograd), just-in-time compilation (JIT), vectorization, and parallel computation
32
+ - Unit conversion and analysis are performed at compilation time, resulting in zero runtime overhead
33
+ - Strict physical unit type checking and dimensional inference system, detecting unit inconsistencies during compilation
34
+
35
+
36
+ ```mermaid
37
+ graph TD
38
+ A[SAIUnit] --> B[Physical Units]
39
+ A --> C[Mathematical Functions]
40
+ A --> D[JAX Integration]
41
+ B --> B1[2000+ Units]
42
+ B --> B2[Physical Constants]
43
+ C --> C1[500+ Unit-aware Functions]
44
+ D --> D1[Autograd]
45
+ D --> D2[JIT Compilation]
46
+ D --> D3[Vectorization]
47
+ D --> D4[Parallelization]
48
+ ```
49
+
50
+ We hope these features establish SAIUnit as a reliable physical unit handling solution for general AI-driven scientific computing scenarios.
51
+
52
+ A quick example:
53
+
54
+ ```python
55
+
56
+ import saiunit as u
57
+
58
+ # Define a physical quantity
59
+ x = 3.0 * u.meter
60
+ x
61
+ # [out] 3. * meter
62
+
63
+ # autograd
64
+ f = lambda x: x ** 3
65
+ u.autograd.grad(f)(x)
66
+ # [out] 27. * meter2
67
+
68
+
69
+ # JIT
70
+ import jax
71
+ jax.jit(f)(x)
72
+ # [out] 27. * klitre
73
+
74
+ # vmap
75
+ jax.vmap(f)(u.math.arange(0. * u.mV, 10. * u.mV, 1. * u.mV))
76
+ # [out] ArrayImpl([ 0., 1., 8., 27., 64., 125., 216., 343., 512., 729.]) * mvolt3
77
+ ```
78
+
79
+
80
+
81
+ ## Installation
82
+
83
+ ``saiunit`` has been well tested on ``python>=3.9`` + ``jax>=0.4.30`` environments, and can be installed on Windows, Linux, and MacOS.
84
+
85
+ You can install ``saiunit`` via pip:
86
+
87
+ ```bash
88
+ pip install saiunit --upgrade
89
+ ```
90
+
91
+ which should install in about 1 minute. If you want to install the latest version from the source, you can clone the repository and install it:
92
+
93
+ ```bash
94
+ git clone https://github.com/chaobrain/saiunit.git
95
+ cd saiunit
96
+ pip install -e .
97
+ ```
98
+
99
+ Alternatively, you can install `BrainX`, which bundles `saiunit` with other compatible packages for a comprehensive brain modeling ecosystem:
100
+
101
+ ```bash
102
+ pip install BrainX -U
103
+ ```
104
+
105
+ ## Documentation
106
+
107
+ The official documentation is hosted on Read the Docs: [https://saiunit.readthedocs.io](https://saiunit.readthedocs.io)
108
+
109
+
110
+
111
+ ## Citation
112
+
113
+ ```bibtex
114
+ @article{wang2025integrating,
115
+ title={Integrating physical units into high-performance AI-driven scientific computing},
116
+ author={Wang, Chaoming and He, Sichao and Luo, Shouwei and Huan, Yuxiang and Wu, Si},
117
+ journal={Nature Communications},
118
+ volume={16},
119
+ number={1},
120
+ pages={3609},
121
+ year={2025},
122
+ publisher={Nature Publishing Group UK London},
123
+ url={https://doi.org/10.1038/s41467-025-58626-4}
124
+ }
125
+ ```
126
+
127
+
128
+ ## Ecosystem
129
+
130
+ `saiunit` has been deeply integrated into following diverse projects, such as:
131
+
132
+ - [``brainstate``](https://github.com/chaobrain/brainstate): A State-based Transformation System for Program Compilation and Augmentation
133
+ - [``braintaichi``](https://github.com/chaobrain/braintaichi): Leveraging Taichi Lang to customize brain dynamics operators
134
+ - [``braintools``](https://github.com/chaobrain/braintools): The Common Toolbox for Brain Dynamics Programming.
135
+ - [``dendritex``](https://github.com/chaobrain/dendritex): Dendritic Modeling in JAX
136
+ - [``pinnx``](https://github.com/chaobrain/pinnx): Physics-Informed Neural Networks for Scientific Machine Learning in JAX.
137
+
138
+
139
+ Other unofficial projects include:
140
+
141
+ - [``diffrax``](https://github.com/chaoming0625/diffrax): Numerical differential equation solvers in JAX.
142
+ - [``jax-md``](https://github.com/Routhleck/jax-md): Differentiable Molecular Dynamics in JAX
143
+ - [``Catalax``](https://github.com/Routhleck/Catalax): JAX-based framework to model biological systems
144
+ - ...
145
+
146
+
147
+ ## Acknowledgement
148
+
149
+ The initial version of the project benefited a lot from the following projects:
150
+
151
+ - [``astropy.units``](https://docs.astropy.org/en/stable/units/index.html): physical units in ``astropy``.
152
+ - [``brian2.units``](https://brian2.readthedocs.io/en/stable/user/units.html): physical units in ``brian2``.
153
+
@@ -0,0 +1,65 @@
1
+ # Copyright 2024 BDP Ecosystem Limited. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ # ==============================================================================
15
+
16
+
17
+ import saiunit
18
+
19
+ __version__ = saiunit.__version__
20
+
21
+ from . import autograd
22
+ from . import constants
23
+ from . import fft
24
+ from . import lax
25
+ from . import linalg
26
+ from . import math
27
+ from . import sparse
28
+ from ._base import *
29
+ from ._base import __all__ as _base_all
30
+ from ._celsius import *
31
+ from ._celsius import __all__ as _celsius_all
32
+ from ._unit_common import *
33
+ from ._unit_common import __all__ as _common_all
34
+ from ._unit_constants import *
35
+ from ._unit_constants import __all__ as _constants_all
36
+ from ._unit_shortcuts import *
37
+ from ._unit_shortcuts import __all__ as _std_units_all
38
+
39
+ __all__ = (
40
+ [
41
+ 'math',
42
+ 'linalg',
43
+ 'autograd',
44
+ 'fft',
45
+ 'constants',
46
+ 'sparse'
47
+ ] +
48
+ _common_all +
49
+ _std_units_all +
50
+ _base_all +
51
+ _constants_all +
52
+ _celsius_all
53
+ )
54
+ del _common_all, _std_units_all, _base_all, _celsius_all, _constants_all, saiunit
55
+
56
+ # old version compatibility
57
+ avogadro_constant = constants.avogadro
58
+ boltzmann_constant = constants.boltzmann
59
+ electric_constant = constants.electric
60
+ electron_mass = constants.electron_mass
61
+ elementary_charge = constants.elementary_charge
62
+ faraday_constant = constants.faraday
63
+ gas_constant = constants.gas
64
+ magnetic_constant = constants.magnetic
65
+ molar_mass_constant = constants.molar_mass
@@ -0,0 +1,20 @@
1
+ # Copyright 2025 BDP Ecosystem Limited. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ # ==============================================================================
15
+
16
+ # -*- coding: utf-8 -*-
17
+
18
+ from saiunit._base import *
19
+ from saiunit._base import __all__
20
+
@@ -0,0 +1,20 @@
1
+ # Copyright 2025 BDP Ecosystem Limited. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ # ==============================================================================
15
+
16
+ # -*- coding: utf-8 -*-
17
+
18
+ from saiunit._celsius import *
19
+ from saiunit._celsius import __all__
20
+
@@ -0,0 +1,19 @@
1
+ # Copyright 2025 BDP Ecosystem Limited. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ # ==============================================================================
15
+
16
+ # -*- coding: utf-8 -*-
17
+
18
+ from saiunit._unit_common import *
19
+ from saiunit._unit_common import __all__