unitforge 0.2.9__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.
- unitforge-0.2.9/.gitignore +11 -0
- unitforge-0.2.9/.gitlab-ci.yml +39 -0
- unitforge-0.2.9/Cargo.lock +370 -0
- unitforge-0.2.9/Cargo.toml +33 -0
- unitforge-0.2.9/PKG-INFO +39 -0
- unitforge-0.2.9/Readme.md +20 -0
- unitforge-0.2.9/Readme_py.md +119 -0
- unitforge-0.2.9/build.rs +280 -0
- unitforge-0.2.9/pyproject.toml +34 -0
- unitforge-0.2.9/src/impl_macros.rs +785 -0
- unitforge-0.2.9/src/lib.rs +89 -0
- unitforge-0.2.9/src/prelude.rs +192 -0
- unitforge-0.2.9/src/quantities/acceleration.rs +49 -0
- unitforge-0.2.9/src/quantities/angle.rs +88 -0
- unitforge-0.2.9/src/quantities/angular_acceleration.rs +46 -0
- unitforge-0.2.9/src/quantities/angular_velocity.rs +48 -0
- unitforge-0.2.9/src/quantities/area.rs +73 -0
- unitforge-0.2.9/src/quantities/area_of_moment.rs +41 -0
- unitforge-0.2.9/src/quantities/charge.rs +38 -0
- unitforge-0.2.9/src/quantities/compliance.rs +40 -0
- unitforge-0.2.9/src/quantities/density.rs +135 -0
- unitforge-0.2.9/src/quantities/distance.rs +117 -0
- unitforge-0.2.9/src/quantities/force.rs +76 -0
- unitforge-0.2.9/src/quantities/force_area.rs +43 -0
- unitforge-0.2.9/src/quantities/force_distance.rs +88 -0
- unitforge-0.2.9/src/quantities/force_div_distance_power_four.rs +46 -0
- unitforge-0.2.9/src/quantities/force_per_volume.rs +51 -0
- unitforge-0.2.9/src/quantities/force_volume.rs +38 -0
- unitforge-0.2.9/src/quantities/inverse_distance.rs +75 -0
- unitforge-0.2.9/src/quantities/mass.rs +116 -0
- unitforge-0.2.9/src/quantities/mass_per_distance_time_square.rs +45 -0
- unitforge-0.2.9/src/quantities/mass_per_time_squared.rs +47 -0
- unitforge-0.2.9/src/quantities/stiffness.rs +46 -0
- unitforge-0.2.9/src/quantities/strain.rs +55 -0
- unitforge-0.2.9/src/quantities/stress.rs +57 -0
- unitforge-0.2.9/src/quantities/stress_squared.rs +42 -0
- unitforge-0.2.9/src/quantities/time.rs +63 -0
- unitforge-0.2.9/src/quantities/velocity.rs +53 -0
- unitforge-0.2.9/src/quantities/velocity_squared.rs +43 -0
- unitforge-0.2.9/src/quantities/voltage.rs +51 -0
- unitforge-0.2.9/src/quantities/volume.rs +73 -0
- unitforge-0.2.9/src/quantities.template.rs +135 -0
- unitforge-0.2.9/src/serde_feature/tests.rs +63 -0
- unitforge-0.2.9/src/small_linalg/bindings/matrix3_py.template.rs +314 -0
- unitforge-0.2.9/src/small_linalg/bindings/vector3_py.template.rs +307 -0
- unitforge-0.2.9/src/small_linalg/matrix3.rs +498 -0
- unitforge-0.2.9/src/small_linalg/vector3.rs +299 -0
- unitforge-0.2.9/tests/quantities.rs +677 -0
- unitforge-0.2.9/tests/small_linalg.rs +622 -0
- unitforge-0.2.9/tests/test_quantities.py +70 -0
- unitforge-0.2.9/tests/test_small_linalg.py +313 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
image: "rust:latest"
|
|
2
|
+
|
|
3
|
+
lint:
|
|
4
|
+
script:
|
|
5
|
+
- rustup component add clippy
|
|
6
|
+
- cargo clippy --no-deps -- -D warnings
|
|
7
|
+
allow_failure: true
|
|
8
|
+
|
|
9
|
+
lint_serde:
|
|
10
|
+
script:
|
|
11
|
+
- rustup component add clippy
|
|
12
|
+
- cargo clippy -F serde --no-deps -- -D warnings
|
|
13
|
+
allow_failure: true
|
|
14
|
+
|
|
15
|
+
lint_pyo3:
|
|
16
|
+
#RUSTFLAGS="-A clippy::useless_conversion" is a workaround for a PyO3 bug remove after switching to newer version
|
|
17
|
+
script:
|
|
18
|
+
- rustup component add clippy
|
|
19
|
+
- RUSTFLAGS="-A clippy::useless_conversion" cargo clippy -F pyo3 --no-deps -- -D warnings
|
|
20
|
+
allow_failure: true
|
|
21
|
+
|
|
22
|
+
test:
|
|
23
|
+
script:
|
|
24
|
+
- rustc --version && cargo --version
|
|
25
|
+
- cargo test --workspace --verbose
|
|
26
|
+
|
|
27
|
+
test_serde:
|
|
28
|
+
script:
|
|
29
|
+
- cargo test -F serde --workspace
|
|
30
|
+
|
|
31
|
+
test_pyo3:
|
|
32
|
+
script:
|
|
33
|
+
- apt-get update && apt-get install -y python3 python3-venv python3.11-dev
|
|
34
|
+
- python3 -m venv .venv
|
|
35
|
+
- source .venv/bin/activate
|
|
36
|
+
- pip install --upgrade pip setuptools wheel maturin pytest numpy
|
|
37
|
+
- maturin develop --features pyo3
|
|
38
|
+
- pytest tests
|
|
39
|
+
- deactivate
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "aho-corasick"
|
|
7
|
+
version = "1.1.3"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
|
|
10
|
+
dependencies = [
|
|
11
|
+
"memchr",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
[[package]]
|
|
15
|
+
name = "autocfg"
|
|
16
|
+
version = "1.4.0"
|
|
17
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
18
|
+
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
|
|
19
|
+
|
|
20
|
+
[[package]]
|
|
21
|
+
name = "cfg-if"
|
|
22
|
+
version = "1.0.0"
|
|
23
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
24
|
+
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
|
25
|
+
|
|
26
|
+
[[package]]
|
|
27
|
+
name = "heck"
|
|
28
|
+
version = "0.5.0"
|
|
29
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
30
|
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
31
|
+
|
|
32
|
+
[[package]]
|
|
33
|
+
name = "indoc"
|
|
34
|
+
version = "2.0.6"
|
|
35
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
36
|
+
checksum = "f4c7245a08504955605670dbf141fceab975f15ca21570696aebe9d2e71576bd"
|
|
37
|
+
|
|
38
|
+
[[package]]
|
|
39
|
+
name = "inventory"
|
|
40
|
+
version = "0.3.20"
|
|
41
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
42
|
+
checksum = "ab08d7cd2c5897f2c949e5383ea7c7db03fb19130ffcfbf7eda795137ae3cb83"
|
|
43
|
+
dependencies = [
|
|
44
|
+
"rustversion",
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
[[package]]
|
|
48
|
+
name = "itoa"
|
|
49
|
+
version = "1.0.15"
|
|
50
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
51
|
+
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
|
|
52
|
+
|
|
53
|
+
[[package]]
|
|
54
|
+
name = "libc"
|
|
55
|
+
version = "0.2.172"
|
|
56
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
57
|
+
checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa"
|
|
58
|
+
|
|
59
|
+
[[package]]
|
|
60
|
+
name = "matrixmultiply"
|
|
61
|
+
version = "0.3.9"
|
|
62
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
63
|
+
checksum = "9380b911e3e96d10c1f415da0876389aaf1b56759054eeb0de7df940c456ba1a"
|
|
64
|
+
dependencies = [
|
|
65
|
+
"autocfg",
|
|
66
|
+
"rawpointer",
|
|
67
|
+
]
|
|
68
|
+
|
|
69
|
+
[[package]]
|
|
70
|
+
name = "memchr"
|
|
71
|
+
version = "2.7.4"
|
|
72
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
73
|
+
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
|
74
|
+
|
|
75
|
+
[[package]]
|
|
76
|
+
name = "memoffset"
|
|
77
|
+
version = "0.9.1"
|
|
78
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
79
|
+
checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
|
|
80
|
+
dependencies = [
|
|
81
|
+
"autocfg",
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
[[package]]
|
|
85
|
+
name = "ndarray"
|
|
86
|
+
version = "0.16.1"
|
|
87
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
88
|
+
checksum = "882ed72dce9365842bf196bdeedf5055305f11fc8c03dee7bb0194a6cad34841"
|
|
89
|
+
dependencies = [
|
|
90
|
+
"matrixmultiply",
|
|
91
|
+
"num-complex",
|
|
92
|
+
"num-integer",
|
|
93
|
+
"num-traits",
|
|
94
|
+
"portable-atomic",
|
|
95
|
+
"portable-atomic-util",
|
|
96
|
+
"rawpointer",
|
|
97
|
+
"serde",
|
|
98
|
+
]
|
|
99
|
+
|
|
100
|
+
[[package]]
|
|
101
|
+
name = "num-complex"
|
|
102
|
+
version = "0.4.6"
|
|
103
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
104
|
+
checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495"
|
|
105
|
+
dependencies = [
|
|
106
|
+
"num-traits",
|
|
107
|
+
]
|
|
108
|
+
|
|
109
|
+
[[package]]
|
|
110
|
+
name = "num-integer"
|
|
111
|
+
version = "0.1.46"
|
|
112
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
113
|
+
checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f"
|
|
114
|
+
dependencies = [
|
|
115
|
+
"num-traits",
|
|
116
|
+
]
|
|
117
|
+
|
|
118
|
+
[[package]]
|
|
119
|
+
name = "num-traits"
|
|
120
|
+
version = "0.2.19"
|
|
121
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
122
|
+
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
|
123
|
+
dependencies = [
|
|
124
|
+
"autocfg",
|
|
125
|
+
]
|
|
126
|
+
|
|
127
|
+
[[package]]
|
|
128
|
+
name = "numpy"
|
|
129
|
+
version = "0.22.1"
|
|
130
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
131
|
+
checksum = "edb929bc0da91a4d85ed6c0a84deaa53d411abfb387fc271124f91bf6b89f14e"
|
|
132
|
+
dependencies = [
|
|
133
|
+
"libc",
|
|
134
|
+
"ndarray",
|
|
135
|
+
"num-complex",
|
|
136
|
+
"num-integer",
|
|
137
|
+
"num-traits",
|
|
138
|
+
"pyo3",
|
|
139
|
+
"rustc-hash",
|
|
140
|
+
]
|
|
141
|
+
|
|
142
|
+
[[package]]
|
|
143
|
+
name = "once_cell"
|
|
144
|
+
version = "1.21.3"
|
|
145
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
146
|
+
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
|
147
|
+
|
|
148
|
+
[[package]]
|
|
149
|
+
name = "portable-atomic"
|
|
150
|
+
version = "1.10.0"
|
|
151
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
152
|
+
checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6"
|
|
153
|
+
|
|
154
|
+
[[package]]
|
|
155
|
+
name = "portable-atomic-util"
|
|
156
|
+
version = "0.2.4"
|
|
157
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
158
|
+
checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507"
|
|
159
|
+
dependencies = [
|
|
160
|
+
"portable-atomic",
|
|
161
|
+
]
|
|
162
|
+
|
|
163
|
+
[[package]]
|
|
164
|
+
name = "proc-macro2"
|
|
165
|
+
version = "1.0.95"
|
|
166
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
167
|
+
checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778"
|
|
168
|
+
dependencies = [
|
|
169
|
+
"unicode-ident",
|
|
170
|
+
]
|
|
171
|
+
|
|
172
|
+
[[package]]
|
|
173
|
+
name = "pyo3"
|
|
174
|
+
version = "0.22.6"
|
|
175
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
176
|
+
checksum = "f402062616ab18202ae8319da13fa4279883a2b8a9d9f83f20dbade813ce1884"
|
|
177
|
+
dependencies = [
|
|
178
|
+
"cfg-if",
|
|
179
|
+
"indoc",
|
|
180
|
+
"inventory",
|
|
181
|
+
"libc",
|
|
182
|
+
"memoffset",
|
|
183
|
+
"once_cell",
|
|
184
|
+
"portable-atomic",
|
|
185
|
+
"pyo3-build-config",
|
|
186
|
+
"pyo3-ffi",
|
|
187
|
+
"pyo3-macros",
|
|
188
|
+
"unindent",
|
|
189
|
+
]
|
|
190
|
+
|
|
191
|
+
[[package]]
|
|
192
|
+
name = "pyo3-build-config"
|
|
193
|
+
version = "0.22.6"
|
|
194
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
195
|
+
checksum = "b14b5775b5ff446dd1056212d778012cbe8a0fbffd368029fd9e25b514479c38"
|
|
196
|
+
dependencies = [
|
|
197
|
+
"once_cell",
|
|
198
|
+
"target-lexicon",
|
|
199
|
+
]
|
|
200
|
+
|
|
201
|
+
[[package]]
|
|
202
|
+
name = "pyo3-ffi"
|
|
203
|
+
version = "0.22.6"
|
|
204
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
205
|
+
checksum = "9ab5bcf04a2cdcbb50c7d6105de943f543f9ed92af55818fd17b660390fc8636"
|
|
206
|
+
dependencies = [
|
|
207
|
+
"libc",
|
|
208
|
+
"pyo3-build-config",
|
|
209
|
+
]
|
|
210
|
+
|
|
211
|
+
[[package]]
|
|
212
|
+
name = "pyo3-macros"
|
|
213
|
+
version = "0.22.6"
|
|
214
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
215
|
+
checksum = "0fd24d897903a9e6d80b968368a34e1525aeb719d568dba8b3d4bfa5dc67d453"
|
|
216
|
+
dependencies = [
|
|
217
|
+
"proc-macro2",
|
|
218
|
+
"pyo3-macros-backend",
|
|
219
|
+
"quote",
|
|
220
|
+
"syn",
|
|
221
|
+
]
|
|
222
|
+
|
|
223
|
+
[[package]]
|
|
224
|
+
name = "pyo3-macros-backend"
|
|
225
|
+
version = "0.22.6"
|
|
226
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
227
|
+
checksum = "36c011a03ba1e50152b4b394b479826cad97e7a21eb52df179cd91ac411cbfbe"
|
|
228
|
+
dependencies = [
|
|
229
|
+
"heck",
|
|
230
|
+
"proc-macro2",
|
|
231
|
+
"pyo3-build-config",
|
|
232
|
+
"quote",
|
|
233
|
+
"syn",
|
|
234
|
+
]
|
|
235
|
+
|
|
236
|
+
[[package]]
|
|
237
|
+
name = "quote"
|
|
238
|
+
version = "1.0.40"
|
|
239
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
240
|
+
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
|
|
241
|
+
dependencies = [
|
|
242
|
+
"proc-macro2",
|
|
243
|
+
]
|
|
244
|
+
|
|
245
|
+
[[package]]
|
|
246
|
+
name = "rawpointer"
|
|
247
|
+
version = "0.2.1"
|
|
248
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
249
|
+
checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3"
|
|
250
|
+
|
|
251
|
+
[[package]]
|
|
252
|
+
name = "regex"
|
|
253
|
+
version = "1.11.1"
|
|
254
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
255
|
+
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
|
|
256
|
+
dependencies = [
|
|
257
|
+
"aho-corasick",
|
|
258
|
+
"memchr",
|
|
259
|
+
"regex-automata",
|
|
260
|
+
"regex-syntax",
|
|
261
|
+
]
|
|
262
|
+
|
|
263
|
+
[[package]]
|
|
264
|
+
name = "regex-automata"
|
|
265
|
+
version = "0.4.9"
|
|
266
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
267
|
+
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
|
|
268
|
+
dependencies = [
|
|
269
|
+
"aho-corasick",
|
|
270
|
+
"memchr",
|
|
271
|
+
"regex-syntax",
|
|
272
|
+
]
|
|
273
|
+
|
|
274
|
+
[[package]]
|
|
275
|
+
name = "regex-syntax"
|
|
276
|
+
version = "0.8.5"
|
|
277
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
278
|
+
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
|
279
|
+
|
|
280
|
+
[[package]]
|
|
281
|
+
name = "rustc-hash"
|
|
282
|
+
version = "1.1.0"
|
|
283
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
284
|
+
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
|
285
|
+
|
|
286
|
+
[[package]]
|
|
287
|
+
name = "rustversion"
|
|
288
|
+
version = "1.0.20"
|
|
289
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
290
|
+
checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2"
|
|
291
|
+
|
|
292
|
+
[[package]]
|
|
293
|
+
name = "ryu"
|
|
294
|
+
version = "1.0.20"
|
|
295
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
296
|
+
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
|
|
297
|
+
|
|
298
|
+
[[package]]
|
|
299
|
+
name = "serde"
|
|
300
|
+
version = "1.0.219"
|
|
301
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
302
|
+
checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
|
|
303
|
+
dependencies = [
|
|
304
|
+
"serde_derive",
|
|
305
|
+
]
|
|
306
|
+
|
|
307
|
+
[[package]]
|
|
308
|
+
name = "serde_derive"
|
|
309
|
+
version = "1.0.219"
|
|
310
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
311
|
+
checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
|
|
312
|
+
dependencies = [
|
|
313
|
+
"proc-macro2",
|
|
314
|
+
"quote",
|
|
315
|
+
"syn",
|
|
316
|
+
]
|
|
317
|
+
|
|
318
|
+
[[package]]
|
|
319
|
+
name = "serde_json"
|
|
320
|
+
version = "1.0.140"
|
|
321
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
322
|
+
checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373"
|
|
323
|
+
dependencies = [
|
|
324
|
+
"itoa",
|
|
325
|
+
"memchr",
|
|
326
|
+
"ryu",
|
|
327
|
+
"serde",
|
|
328
|
+
]
|
|
329
|
+
|
|
330
|
+
[[package]]
|
|
331
|
+
name = "syn"
|
|
332
|
+
version = "2.0.100"
|
|
333
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
334
|
+
checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0"
|
|
335
|
+
dependencies = [
|
|
336
|
+
"proc-macro2",
|
|
337
|
+
"quote",
|
|
338
|
+
"unicode-ident",
|
|
339
|
+
]
|
|
340
|
+
|
|
341
|
+
[[package]]
|
|
342
|
+
name = "target-lexicon"
|
|
343
|
+
version = "0.12.16"
|
|
344
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
345
|
+
checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
|
|
346
|
+
|
|
347
|
+
[[package]]
|
|
348
|
+
name = "unicode-ident"
|
|
349
|
+
version = "1.0.18"
|
|
350
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
351
|
+
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
|
352
|
+
|
|
353
|
+
[[package]]
|
|
354
|
+
name = "unindent"
|
|
355
|
+
version = "0.2.4"
|
|
356
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
357
|
+
checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3"
|
|
358
|
+
|
|
359
|
+
[[package]]
|
|
360
|
+
name = "unitforge"
|
|
361
|
+
version = "0.2.9"
|
|
362
|
+
dependencies = [
|
|
363
|
+
"ndarray",
|
|
364
|
+
"num-traits",
|
|
365
|
+
"numpy",
|
|
366
|
+
"pyo3",
|
|
367
|
+
"regex",
|
|
368
|
+
"serde",
|
|
369
|
+
"serde_json",
|
|
370
|
+
]
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
[lib]
|
|
2
|
+
name = "unitforge"
|
|
3
|
+
crate-type = ["rlib"]
|
|
4
|
+
|
|
5
|
+
[package]
|
|
6
|
+
name = "unitforge"
|
|
7
|
+
version = "0.2.9"
|
|
8
|
+
edition = "2021"
|
|
9
|
+
authors = ["Dr.Q team <info@askdrq.com>", "Henrik Stromberg <henrik@askdrq.com>"]
|
|
10
|
+
description = "A library for unit and quantity consistent computations in Rust"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
repository = "https://gitlab.com/henrikjstromberg/unitforge"
|
|
13
|
+
keywords = ["units", "quantities", "simulation", "physics"]
|
|
14
|
+
readme = "Readme.md"
|
|
15
|
+
#ToDo: documentation
|
|
16
|
+
|
|
17
|
+
[dependencies]
|
|
18
|
+
ndarray = {version = "0.16"}
|
|
19
|
+
num-traits = "0.2.18"
|
|
20
|
+
serde = { version = "1", optional = true, features = ["derive"]}
|
|
21
|
+
serde_json = { version = "1.0.140", optional = true}
|
|
22
|
+
pyo3 = { version = "0.22", features = [
|
|
23
|
+
"auto-initialize",
|
|
24
|
+
"multiple-pymethods",
|
|
25
|
+
] , optional = true}
|
|
26
|
+
numpy = {version = "0.22.0", optional = true}
|
|
27
|
+
|
|
28
|
+
[build-dependencies]
|
|
29
|
+
regex = "1.11.1"
|
|
30
|
+
|
|
31
|
+
[features]
|
|
32
|
+
serde = ["dep:serde","dep:serde_json","ndarray/serde"]
|
|
33
|
+
pyo3 = ["dep:pyo3", "dep:numpy", "pyo3/extension-module"]
|
unitforge-0.2.9/PKG-INFO
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: unitforge
|
|
3
|
+
Version: 0.2.9
|
|
4
|
+
Classifier: Programming Language :: Python :: 3
|
|
5
|
+
Classifier: Programming Language :: Rust
|
|
6
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
7
|
+
Classifier: Operating System :: OS Independent
|
|
8
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
9
|
+
Requires-Dist: numpy>=2.2.0
|
|
10
|
+
Summary: A library for unit and quantity consistent computations in Rust
|
|
11
|
+
Keywords: units,quantities,simulation,physics
|
|
12
|
+
Author: Dr.Q team <info@askdrq.com>, Henrik Stromberg <henrik@askdrq.com>
|
|
13
|
+
Author-email: "Dr.Q team" <info@askdrq.com>, Henrik Stromberg <henrik@askdrq.com>
|
|
14
|
+
License: MIT
|
|
15
|
+
Requires-Python: >=3.7
|
|
16
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
17
|
+
Project-URL: Repository, https://gitlab.com/henrikjstromberg/unitforge
|
|
18
|
+
|
|
19
|
+
# Unitforge
|
|
20
|
+
|
|
21
|
+
## Overview
|
|
22
|
+
|
|
23
|
+
**Unitforge** is a Rust crate designed for safe handling of physical quantities of units. New quantities and relations can be set up via small macros.
|
|
24
|
+
|
|
25
|
+
## Features
|
|
26
|
+
|
|
27
|
+
- **Quantity inference:** Resulting quantities of arithmetic operations are inferred at compile time.
|
|
28
|
+
- **Unit conversion:** Quantities can be set or read in arbitrary units.
|
|
29
|
+
- **Computing Precision** Values are stored in exponential format (f64*10^i32) to prevent floating point precision issues.
|
|
30
|
+
- **Formating** Quantities are displayed with 4 significant digits and configured display unit.
|
|
31
|
+
- **ndarray support:** Quantities may be used as inner types for `ndarray`.
|
|
32
|
+
- **3D Vector and matrix operations:** Structs for 3D vectors and matrices are included to allow fast and unit-safe work with them.
|
|
33
|
+
- **Serialization**: Optional support for sere using the serde feature.
|
|
34
|
+
- **python interface** Optional Python interface when building with flag pyo3; also available on pypi
|
|
35
|
+
|
|
36
|
+
## Contribute
|
|
37
|
+
|
|
38
|
+
All contributions are welcome! Feel free to implement new quantities or define relations using `impl_macros.rs`. 🚀
|
|
39
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Unitforge
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
**Unitforge** is a Rust crate designed for safe handling of physical quantities of units. New quantities and relations can be set up via small macros.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Quantity inference:** Resulting quantities of arithmetic operations are inferred at compile time.
|
|
10
|
+
- **Unit conversion:** Quantities can be set or read in arbitrary units.
|
|
11
|
+
- **Computing Precision** Values are stored in exponential format (f64*10^i32) to prevent floating point precision issues.
|
|
12
|
+
- **Formating** Quantities are displayed with 4 significant digits and configured display unit.
|
|
13
|
+
- **ndarray support:** Quantities may be used as inner types for `ndarray`.
|
|
14
|
+
- **3D Vector and matrix operations:** Structs for 3D vectors and matrices are included to allow fast and unit-safe work with them.
|
|
15
|
+
- **Serialization**: Optional support for sere using the serde feature.
|
|
16
|
+
- **python interface** Optional Python interface when building with flag pyo3; also available on pypi
|
|
17
|
+
|
|
18
|
+
## Contribute
|
|
19
|
+
|
|
20
|
+
All contributions are welcome! Feel free to implement new quantities or define relations using `impl_macros.rs`. 🚀
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Unitforge
|
|
2
|
+
|
|
3
|
+
**Unitforge** is a Python library for working with physical quantities that respect units, dimensional analysis, and arithmetic correctness — powered by high-performance Rust under the hood.
|
|
4
|
+
|
|
5
|
+
Built for scientific computing, simulation, and engineering workflows where unit safety is non-negotiable.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- **Strong unit enforcement**: Prevent unit mismatch bugs at runtime.
|
|
12
|
+
- **Arithmetic support**: Add, subtract, multiply, and divide quantities with automatic unit resolution.
|
|
13
|
+
- **Unit conversion**: Convert between compatible units on the fly.
|
|
14
|
+
- **Scientific formatting**: Values display with 4 significant digits and the configured unit.
|
|
15
|
+
- **3D Vectors & Matrices**: Perform vector/matrix math with quantities and units.
|
|
16
|
+
- **NumPy integration**: Convert to/from NumPy arrays easily.
|
|
17
|
+
- **Constants**: Built-in constants like the speed of light.
|
|
18
|
+
- **Serialization-ready**: Optional serde-based serialization support (if compiled with feature).
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install unitforge
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Example Usage
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from unitforge import Force, ForceUnit, Distance, DistanceUnit
|
|
34
|
+
|
|
35
|
+
f = Force(12.0, ForceUnit.N)
|
|
36
|
+
print(f.to(ForceUnit.mN)) # → 12000.0
|
|
37
|
+
|
|
38
|
+
d = Distance(2.0, DistanceUnit.m)
|
|
39
|
+
work = f * d
|
|
40
|
+
print(work) # → 24 Nm
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Unit Conversion
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
f = Force(1.0, ForceUnit.N)
|
|
47
|
+
print(f.to(ForceUnit.kN)) # → 0.001
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Arithmetic
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
f1 = Force(5.0, ForceUnit.N)
|
|
54
|
+
f2 = Force(3.0, ForceUnit.N)
|
|
55
|
+
f_sum = f1 + f2
|
|
56
|
+
print(f_sum.to(ForceUnit.N)) # → 8.0
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Vector and Matrix Support
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
from unitforge import Vector3, Distance, DistanceUnit
|
|
65
|
+
|
|
66
|
+
v = Vector3.from_list([
|
|
67
|
+
Distance(3., DistanceUnit.m),
|
|
68
|
+
Distance(4., DistanceUnit.m),
|
|
69
|
+
Distance(12., DistanceUnit.m)
|
|
70
|
+
])
|
|
71
|
+
|
|
72
|
+
print(v.norm()) # → 13.0 m
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## NumPy Interoperability
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
import numpy as np
|
|
81
|
+
from unitforge import Vector3, ForceUnit
|
|
82
|
+
|
|
83
|
+
arr = np.array([1.0, 2.0, 3.0])
|
|
84
|
+
vec = Vector3.from_array(arr, ForceUnit.N)
|
|
85
|
+
arr_back = vec.to_array(ForceUnit.N)
|
|
86
|
+
|
|
87
|
+
print(arr_back) # → [1. 2. 3.]
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Quantities Available
|
|
93
|
+
|
|
94
|
+
Examples include:
|
|
95
|
+
|
|
96
|
+
- `Acceleration`, `AreaOfMoment`, `Density`, `Stiffness`, `Time`, `Volume`, `Angle`, `Area`, `Distance`, `ForcePerVolume`, `Strain`, `Velocity`, `AngularAcceleration`, `Charge`, `ForceArea`, `Force`, `Stress`, `VelocitySquared`, `AngularVelocity`, `Compliance`, `ForceDistance`, `ForceVolume`, `Mass`, `Voltage`
|
|
97
|
+
- Each with associated unit enums (e.g., `ForceUnit`, `DistanceUnit`, ...)
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
from math import isclose
|
|
103
|
+
from unitforge import Force, ForceUnit
|
|
104
|
+
|
|
105
|
+
f = Force(12., ForceUnit.N)
|
|
106
|
+
assert isclose((f * 2).to(ForceUnit.N), 24.)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Contributing
|
|
112
|
+
|
|
113
|
+
Contributions are welcome! While the core is implemented in Rust, Python usage feedback, bug reports, and API improvements are highly valued.
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## Repository
|
|
118
|
+
|
|
119
|
+
[GitLab – Unitforge Crate](https://gitlab.com/henrikjstromberg/unitforge)
|