dimvexa 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dimvexa-0.1.0/Cargo.toml +86 -0
- dimvexa-0.1.0/PKG-INFO +53 -0
- dimvexa-0.1.0/README.md +36 -0
- dimvexa-0.1.0/bindings/python/Cargo.lock +248 -0
- dimvexa-0.1.0/bindings/python/Cargo.toml +23 -0
- dimvexa-0.1.0/bindings/python/README.md +36 -0
- dimvexa-0.1.0/bindings/python/src/lib.rs +299 -0
- dimvexa-0.1.0/bindings/python/tests/test_dimvexa.py +71 -0
- dimvexa-0.1.0/crates/dimvexa/Cargo.toml +27 -0
- dimvexa-0.1.0/crates/dimvexa/README.md +5 -0
- dimvexa-0.1.0/crates/dimvexa/benches/m0.rs +480 -0
- dimvexa-0.1.0/crates/dimvexa/src/lib.rs +43 -0
- dimvexa-0.1.0/crates/dimvexa/tests/pool_pump.rs +50 -0
- dimvexa-0.1.0/crates/dimvexa-core/Cargo.toml +20 -0
- dimvexa-0.1.0/crates/dimvexa-core/README.md +8 -0
- dimvexa-0.1.0/crates/dimvexa-core/src/conversion.rs +530 -0
- dimvexa-0.1.0/crates/dimvexa-core/src/dim.rs +194 -0
- dimvexa-0.1.0/crates/dimvexa-core/src/error.rs +281 -0
- dimvexa-0.1.0/crates/dimvexa-core/src/expr.rs +487 -0
- dimvexa-0.1.0/crates/dimvexa-core/src/kind.rs +267 -0
- dimvexa-0.1.0/crates/dimvexa-core/src/lib.rs +75 -0
- dimvexa-0.1.0/crates/dimvexa-core/src/prefix.rs +197 -0
- dimvexa-0.1.0/crates/dimvexa-core/src/quantity.rs +242 -0
- dimvexa-0.1.0/crates/dimvexa-core/src/ratio.rs +801 -0
- dimvexa-0.1.0/crates/dimvexa-core/src/registry.rs +804 -0
- dimvexa-0.1.0/crates/dimvexa-core/src/unit.rs +645 -0
- dimvexa-0.1.0/crates/dimvexa-data/Cargo.toml +24 -0
- dimvexa-0.1.0/crates/dimvexa-data/README.md +5 -0
- dimvexa-0.1.0/crates/dimvexa-data/build.rs +218 -0
- dimvexa-0.1.0/crates/dimvexa-data/data/data_version.toml +6 -0
- dimvexa-0.1.0/crates/dimvexa-data/data/units/ambiguous.toml +117 -0
- dimvexa-0.1.0/crates/dimvexa-data/data/units/base.toml +591 -0
- dimvexa-0.1.0/crates/dimvexa-data/data/units/common.toml +760 -0
- dimvexa-0.1.0/crates/dimvexa-data/data/vectors/base.toml +421 -0
- dimvexa-0.1.0/crates/dimvexa-data/data/vectors/common.toml +504 -0
- dimvexa-0.1.0/crates/dimvexa-data/src/lib.rs +80 -0
- dimvexa-0.1.0/crates/dimvexa-data/tests/golden.rs +307 -0
- dimvexa-0.1.0/crates/dimvexa-data/tooling/toml_lite.rs +281 -0
- dimvexa-0.1.0/pyproject.toml +50 -0
- dimvexa-0.1.0/python/dimvexa/__init__.py +27 -0
- dimvexa-0.1.0/python/dimvexa/_dimvexa.pyi +38 -0
- dimvexa-0.1.0/python/dimvexa/py.typed +0 -0
dimvexa-0.1.0/Cargo.toml
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
[workspace]
|
|
2
|
+
resolver = "3"
|
|
3
|
+
members = [
|
|
4
|
+
"crates/dimvexa-core",
|
|
5
|
+
"crates/dimvexa-data",
|
|
6
|
+
"crates/dimvexa-config",
|
|
7
|
+
"crates/dimvexa",
|
|
8
|
+
"crates/dimvexa-testkit",
|
|
9
|
+
"crates/dimvexa-cli",
|
|
10
|
+
"xtask",
|
|
11
|
+
]
|
|
12
|
+
default-members = [
|
|
13
|
+
"crates/dimvexa-core",
|
|
14
|
+
"crates/dimvexa-data",
|
|
15
|
+
"crates/dimvexa-config",
|
|
16
|
+
"crates/dimvexa",
|
|
17
|
+
"crates/dimvexa-testkit",
|
|
18
|
+
"crates/dimvexa-cli",
|
|
19
|
+
]
|
|
20
|
+
# extras/ holds the network-only dev tooling (proptest, criterion, iai-callgrind,
|
|
21
|
+
# insta, assert_cmd). It is a separate workspace so the main workspace builds offline.
|
|
22
|
+
# benchmarks/ holds the cross-library comparison runners; each Rust runner there is its own
|
|
23
|
+
# workspace too, and the competitor libraries are never installed by the main CI.
|
|
24
|
+
exclude = ["extras", "fuzz", "benchmarks", "bindings"]
|
|
25
|
+
|
|
26
|
+
[workspace.package]
|
|
27
|
+
version = "0.1.0"
|
|
28
|
+
edition = "2024"
|
|
29
|
+
rust-version = "1.85"
|
|
30
|
+
license = "MIT OR Apache-2.0"
|
|
31
|
+
repository = "https://github.com/welworx/dimvexa"
|
|
32
|
+
homepage = "https://github.com/welworx/dimvexa"
|
|
33
|
+
documentation = "https://docs.rs/dimvexa"
|
|
34
|
+
readme = "README.md"
|
|
35
|
+
authors = ["The Dimvexa contributors"]
|
|
36
|
+
keywords = ["units", "unit-conversion", "dimensional-analysis", "science", "engineering"]
|
|
37
|
+
categories = ["science", "mathematics"]
|
|
38
|
+
|
|
39
|
+
[workspace.dependencies]
|
|
40
|
+
dimvexa-core = { version = "0.1.0", path = "crates/dimvexa-core" }
|
|
41
|
+
dimvexa-data = { version = "0.1.0", path = "crates/dimvexa-data" }
|
|
42
|
+
dimvexa-config = { version = "0.1.0", path = "crates/dimvexa-config" }
|
|
43
|
+
dimvexa = { version = "0.1.0", path = "crates/dimvexa" }
|
|
44
|
+
dimvexa-testkit = { version = "0.1.0", path = "crates/dimvexa-testkit" }
|
|
45
|
+
|
|
46
|
+
[workspace.lints.rust]
|
|
47
|
+
unsafe_code = "forbid"
|
|
48
|
+
missing_docs = "deny"
|
|
49
|
+
unreachable_pub = "warn"
|
|
50
|
+
unused_must_use = "deny"
|
|
51
|
+
rust_2018_idioms = { level = "warn", priority = -1 }
|
|
52
|
+
missing_debug_implementations = "warn"
|
|
53
|
+
|
|
54
|
+
[workspace.lints.clippy]
|
|
55
|
+
all = { level = "deny", priority = -1 }
|
|
56
|
+
pedantic = { level = "warn", priority = -1 }
|
|
57
|
+
nursery = { level = "warn", priority = -1 }
|
|
58
|
+
cargo = { level = "warn", priority = -1 }
|
|
59
|
+
unwrap_used = "deny"
|
|
60
|
+
expect_used = "deny"
|
|
61
|
+
panic = "deny"
|
|
62
|
+
indexing_slicing = "deny"
|
|
63
|
+
arithmetic_side_effects = "deny"
|
|
64
|
+
cast_possible_truncation = "deny"
|
|
65
|
+
cast_precision_loss = "deny"
|
|
66
|
+
float_cmp = "deny"
|
|
67
|
+
dbg_macro = "deny"
|
|
68
|
+
todo = "deny"
|
|
69
|
+
unimplemented = "deny"
|
|
70
|
+
print_stdout = "deny"
|
|
71
|
+
print_stderr = "deny"
|
|
72
|
+
|
|
73
|
+
[profile.release]
|
|
74
|
+
debug = 1
|
|
75
|
+
lto = "thin"
|
|
76
|
+
codegen-units = 1
|
|
77
|
+
|
|
78
|
+
[profile.bench]
|
|
79
|
+
inherits = "release"
|
|
80
|
+
|
|
81
|
+
# Used by `cargo xtask ci` and the CI workflow: the dev profile with smaller debug info and
|
|
82
|
+
# no incremental cache (CI builds from scratch, so incremental data is wasted disk and time).
|
|
83
|
+
[profile.ci]
|
|
84
|
+
inherits = "dev"
|
|
85
|
+
debug = "line-tables-only"
|
|
86
|
+
incremental = false
|
dimvexa-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dimvexa
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Classifier: Programming Language :: Rust
|
|
5
|
+
Classifier: Topic :: Scientific/Engineering
|
|
6
|
+
Classifier: Typing :: Typed
|
|
7
|
+
Requires-Dist: numpy>=1.23 ; extra == 'numpy'
|
|
8
|
+
Requires-Dist: pytest ; extra == 'test'
|
|
9
|
+
Requires-Dist: numpy>=1.23 ; extra == 'test'
|
|
10
|
+
Provides-Extra: numpy
|
|
11
|
+
Provides-Extra: test
|
|
12
|
+
Summary: Exact factors. Loud failures. Zero guessing. Unit conversion with exact rational factors.
|
|
13
|
+
License: MIT OR Apache-2.0
|
|
14
|
+
Requires-Python: >=3.9
|
|
15
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
16
|
+
|
|
17
|
+
# dimvexa (Python)
|
|
18
|
+
|
|
19
|
+
Python binding for [Dimvexa](https://github.com/welworx/dimvexa): *Exact factors. Loud failures.
|
|
20
|
+
Zero guessing.* A thin PyO3 layer; all conversion logic is in the Rust core.
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
import dimvexa
|
|
24
|
+
|
|
25
|
+
dimvexa.convert(10.0, "m/s", "km/h") # 36.0
|
|
26
|
+
c = dimvexa.conversion("m", "km") # parse once ...
|
|
27
|
+
c(numpy_array) # ... apply to float64 arrays, lists or floats
|
|
28
|
+
|
|
29
|
+
try:
|
|
30
|
+
dimvexa.convert(1.0, "gal", "L")
|
|
31
|
+
except dimvexa.DimvexaError as e:
|
|
32
|
+
e.code, e.candidates # 'ambiguous_symbol', ['gal_us', 'gal_imp']
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Every refusal is a `DimvexaError` (a `ValueError`) with a stable `code`, `suggestions` and
|
|
36
|
+
`candidates`. `exact=True` routes through the exact rational path, rounded once.
|
|
37
|
+
|
|
38
|
+
## Build and test
|
|
39
|
+
|
|
40
|
+
This crate is its own workspace (it needs PyO3 and NumPy from the registry; the main workspace is
|
|
41
|
+
std-only and offline). It is not part of `cargo xtask ci`.
|
|
42
|
+
|
|
43
|
+
```console
|
|
44
|
+
cd bindings/python
|
|
45
|
+
python -m venv .venv && . .venv/bin/activate
|
|
46
|
+
pip install maturin pytest numpy
|
|
47
|
+
maturin develop
|
|
48
|
+
pytest
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Wheels are `abi3` (Python 3.9+). No performance claim is made until a dated benchmark run exists
|
|
52
|
+
(`docs/benchmarking.md`).
|
|
53
|
+
|
dimvexa-0.1.0/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# dimvexa (Python)
|
|
2
|
+
|
|
3
|
+
Python binding for [Dimvexa](https://github.com/welworx/dimvexa): *Exact factors. Loud failures.
|
|
4
|
+
Zero guessing.* A thin PyO3 layer; all conversion logic is in the Rust core.
|
|
5
|
+
|
|
6
|
+
```python
|
|
7
|
+
import dimvexa
|
|
8
|
+
|
|
9
|
+
dimvexa.convert(10.0, "m/s", "km/h") # 36.0
|
|
10
|
+
c = dimvexa.conversion("m", "km") # parse once ...
|
|
11
|
+
c(numpy_array) # ... apply to float64 arrays, lists or floats
|
|
12
|
+
|
|
13
|
+
try:
|
|
14
|
+
dimvexa.convert(1.0, "gal", "L")
|
|
15
|
+
except dimvexa.DimvexaError as e:
|
|
16
|
+
e.code, e.candidates # 'ambiguous_symbol', ['gal_us', 'gal_imp']
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Every refusal is a `DimvexaError` (a `ValueError`) with a stable `code`, `suggestions` and
|
|
20
|
+
`candidates`. `exact=True` routes through the exact rational path, rounded once.
|
|
21
|
+
|
|
22
|
+
## Build and test
|
|
23
|
+
|
|
24
|
+
This crate is its own workspace (it needs PyO3 and NumPy from the registry; the main workspace is
|
|
25
|
+
std-only and offline). It is not part of `cargo xtask ci`.
|
|
26
|
+
|
|
27
|
+
```console
|
|
28
|
+
cd bindings/python
|
|
29
|
+
python -m venv .venv && . .venv/bin/activate
|
|
30
|
+
pip install maturin pytest numpy
|
|
31
|
+
maturin develop
|
|
32
|
+
pytest
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Wheels are `abi3` (Python 3.9+). No performance claim is made until a dated benchmark run exists
|
|
36
|
+
(`docs/benchmarking.md`).
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "autocfg"
|
|
7
|
+
version = "1.5.1"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
|
|
10
|
+
|
|
11
|
+
[[package]]
|
|
12
|
+
name = "dimvexa"
|
|
13
|
+
version = "0.1.0"
|
|
14
|
+
dependencies = [
|
|
15
|
+
"dimvexa-core",
|
|
16
|
+
"dimvexa-data",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[[package]]
|
|
20
|
+
name = "dimvexa-core"
|
|
21
|
+
version = "0.1.0"
|
|
22
|
+
|
|
23
|
+
[[package]]
|
|
24
|
+
name = "dimvexa-data"
|
|
25
|
+
version = "0.1.0"
|
|
26
|
+
dependencies = [
|
|
27
|
+
"dimvexa-core",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[[package]]
|
|
31
|
+
name = "dimvexa-python"
|
|
32
|
+
version = "0.1.0"
|
|
33
|
+
dependencies = [
|
|
34
|
+
"dimvexa",
|
|
35
|
+
"numpy",
|
|
36
|
+
"pyo3",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
[[package]]
|
|
40
|
+
name = "heck"
|
|
41
|
+
version = "0.5.0"
|
|
42
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
43
|
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
44
|
+
|
|
45
|
+
[[package]]
|
|
46
|
+
name = "libc"
|
|
47
|
+
version = "0.2.191"
|
|
48
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
49
|
+
checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
|
|
50
|
+
|
|
51
|
+
[[package]]
|
|
52
|
+
name = "matrixmultiply"
|
|
53
|
+
version = "0.3.11"
|
|
54
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
55
|
+
checksum = "3f607c237553f086e7043417a51df26b2eb899d3caff94e6a67592ff992fedc7"
|
|
56
|
+
dependencies = [
|
|
57
|
+
"autocfg",
|
|
58
|
+
"rawpointer",
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
[[package]]
|
|
62
|
+
name = "ndarray"
|
|
63
|
+
version = "0.17.2"
|
|
64
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
65
|
+
checksum = "520080814a7a6b4a6e9070823bb24b4531daac8c4627e08ba5de8c5ef2f2752d"
|
|
66
|
+
dependencies = [
|
|
67
|
+
"matrixmultiply",
|
|
68
|
+
"num-complex",
|
|
69
|
+
"num-integer",
|
|
70
|
+
"num-traits",
|
|
71
|
+
"portable-atomic",
|
|
72
|
+
"portable-atomic-util",
|
|
73
|
+
"rawpointer",
|
|
74
|
+
]
|
|
75
|
+
|
|
76
|
+
[[package]]
|
|
77
|
+
name = "num-complex"
|
|
78
|
+
version = "0.4.6"
|
|
79
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
80
|
+
checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495"
|
|
81
|
+
dependencies = [
|
|
82
|
+
"num-traits",
|
|
83
|
+
]
|
|
84
|
+
|
|
85
|
+
[[package]]
|
|
86
|
+
name = "num-integer"
|
|
87
|
+
version = "0.1.47"
|
|
88
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
89
|
+
checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b"
|
|
90
|
+
dependencies = [
|
|
91
|
+
"num-traits",
|
|
92
|
+
]
|
|
93
|
+
|
|
94
|
+
[[package]]
|
|
95
|
+
name = "num-traits"
|
|
96
|
+
version = "0.2.19"
|
|
97
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
98
|
+
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
|
99
|
+
dependencies = [
|
|
100
|
+
"autocfg",
|
|
101
|
+
]
|
|
102
|
+
|
|
103
|
+
[[package]]
|
|
104
|
+
name = "numpy"
|
|
105
|
+
version = "0.30.0"
|
|
106
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
107
|
+
checksum = "aa0b9111761885449e894981fa8051dcf69e0bd114aecbd4bcdd830b6be4ed92"
|
|
108
|
+
dependencies = [
|
|
109
|
+
"libc",
|
|
110
|
+
"ndarray",
|
|
111
|
+
"num-complex",
|
|
112
|
+
"num-integer",
|
|
113
|
+
"num-traits",
|
|
114
|
+
"pyo3",
|
|
115
|
+
"pyo3-build-config",
|
|
116
|
+
"rustc-hash",
|
|
117
|
+
]
|
|
118
|
+
|
|
119
|
+
[[package]]
|
|
120
|
+
name = "once_cell"
|
|
121
|
+
version = "1.21.4"
|
|
122
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
123
|
+
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
|
124
|
+
|
|
125
|
+
[[package]]
|
|
126
|
+
name = "portable-atomic"
|
|
127
|
+
version = "1.15.0"
|
|
128
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
129
|
+
checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
|
|
130
|
+
|
|
131
|
+
[[package]]
|
|
132
|
+
name = "portable-atomic-util"
|
|
133
|
+
version = "0.2.8"
|
|
134
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
135
|
+
checksum = "10ab3eb7f3becc3a1cbc4f2c6f20267996cfc1a6467a873763411b136a122715"
|
|
136
|
+
dependencies = [
|
|
137
|
+
"portable-atomic",
|
|
138
|
+
]
|
|
139
|
+
|
|
140
|
+
[[package]]
|
|
141
|
+
name = "proc-macro2"
|
|
142
|
+
version = "1.0.107"
|
|
143
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
144
|
+
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
|
145
|
+
dependencies = [
|
|
146
|
+
"unicode-ident",
|
|
147
|
+
]
|
|
148
|
+
|
|
149
|
+
[[package]]
|
|
150
|
+
name = "pyo3"
|
|
151
|
+
version = "0.30.1"
|
|
152
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
153
|
+
checksum = "229ca13b8a15bb0d1487b81ab975bfcd97513416499a8312011b6036e42e0de4"
|
|
154
|
+
dependencies = [
|
|
155
|
+
"libc",
|
|
156
|
+
"once_cell",
|
|
157
|
+
"portable-atomic",
|
|
158
|
+
"pyo3-build-config",
|
|
159
|
+
"pyo3-ffi",
|
|
160
|
+
"pyo3-macros",
|
|
161
|
+
]
|
|
162
|
+
|
|
163
|
+
[[package]]
|
|
164
|
+
name = "pyo3-build-config"
|
|
165
|
+
version = "0.30.1"
|
|
166
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
167
|
+
checksum = "70130e2b6dd1ee589a8788026a429561ca5c40fa7a2fa7914c2282eddae24700"
|
|
168
|
+
dependencies = [
|
|
169
|
+
"target-lexicon",
|
|
170
|
+
]
|
|
171
|
+
|
|
172
|
+
[[package]]
|
|
173
|
+
name = "pyo3-ffi"
|
|
174
|
+
version = "0.30.1"
|
|
175
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
176
|
+
checksum = "5e7ff73c555c286d212d4ce7e5fbda845a973c4f61bd5f160f5f2c3c2a04d1c4"
|
|
177
|
+
dependencies = [
|
|
178
|
+
"libc",
|
|
179
|
+
"pyo3-build-config",
|
|
180
|
+
]
|
|
181
|
+
|
|
182
|
+
[[package]]
|
|
183
|
+
name = "pyo3-macros"
|
|
184
|
+
version = "0.30.1"
|
|
185
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
186
|
+
checksum = "c46d2e5862c7bb8207e3b639f713dda3c499933444784154c11d013c5a691b60"
|
|
187
|
+
dependencies = [
|
|
188
|
+
"proc-macro2",
|
|
189
|
+
"pyo3-macros-backend",
|
|
190
|
+
"quote",
|
|
191
|
+
"syn",
|
|
192
|
+
]
|
|
193
|
+
|
|
194
|
+
[[package]]
|
|
195
|
+
name = "pyo3-macros-backend"
|
|
196
|
+
version = "0.30.1"
|
|
197
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
198
|
+
checksum = "38b89f066f2ae72a2aef52d1537ca2fcd104440ebfadee06e97aa90738a25b9b"
|
|
199
|
+
dependencies = [
|
|
200
|
+
"heck",
|
|
201
|
+
"proc-macro2",
|
|
202
|
+
"quote",
|
|
203
|
+
"syn",
|
|
204
|
+
]
|
|
205
|
+
|
|
206
|
+
[[package]]
|
|
207
|
+
name = "quote"
|
|
208
|
+
version = "1.0.47"
|
|
209
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
210
|
+
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
|
211
|
+
dependencies = [
|
|
212
|
+
"proc-macro2",
|
|
213
|
+
]
|
|
214
|
+
|
|
215
|
+
[[package]]
|
|
216
|
+
name = "rawpointer"
|
|
217
|
+
version = "0.2.1"
|
|
218
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
219
|
+
checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3"
|
|
220
|
+
|
|
221
|
+
[[package]]
|
|
222
|
+
name = "rustc-hash"
|
|
223
|
+
version = "2.1.3"
|
|
224
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
225
|
+
checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d"
|
|
226
|
+
|
|
227
|
+
[[package]]
|
|
228
|
+
name = "syn"
|
|
229
|
+
version = "3.0.9"
|
|
230
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
231
|
+
checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b"
|
|
232
|
+
dependencies = [
|
|
233
|
+
"proc-macro2",
|
|
234
|
+
"quote",
|
|
235
|
+
"unicode-ident",
|
|
236
|
+
]
|
|
237
|
+
|
|
238
|
+
[[package]]
|
|
239
|
+
name = "target-lexicon"
|
|
240
|
+
version = "0.13.5"
|
|
241
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
242
|
+
checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
|
|
243
|
+
|
|
244
|
+
[[package]]
|
|
245
|
+
name = "unicode-ident"
|
|
246
|
+
version = "1.0.27"
|
|
247
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
248
|
+
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Python binding (PyO3 + maturin). Its own workspace: the main workspace is std-only and builds
|
|
2
|
+
# offline, and this crate needs PyO3 and NumPy from the registry. See README.md and ADR-011.
|
|
3
|
+
[package]
|
|
4
|
+
name = "dimvexa-python"
|
|
5
|
+
version = "0.1.0"
|
|
6
|
+
edition = "2024"
|
|
7
|
+
rust-version = "1.85"
|
|
8
|
+
license = "MIT OR Apache-2.0"
|
|
9
|
+
repository = "https://github.com/welworx/dimvexa"
|
|
10
|
+
description = "Python binding for Dimvexa"
|
|
11
|
+
publish = false
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
|
|
14
|
+
[workspace]
|
|
15
|
+
|
|
16
|
+
[lib]
|
|
17
|
+
name = "_dimvexa"
|
|
18
|
+
crate-type = ["cdylib"]
|
|
19
|
+
|
|
20
|
+
[dependencies]
|
|
21
|
+
dimvexa = { version = "0.1.0", path = "../../crates/dimvexa" }
|
|
22
|
+
pyo3 = { version = "0.30", features = ["abi3-py39", "extension-module"] }
|
|
23
|
+
numpy = "0.30"
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# dimvexa (Python)
|
|
2
|
+
|
|
3
|
+
Python binding for [Dimvexa](https://github.com/welworx/dimvexa): *Exact factors. Loud failures.
|
|
4
|
+
Zero guessing.* A thin PyO3 layer; all conversion logic is in the Rust core.
|
|
5
|
+
|
|
6
|
+
```python
|
|
7
|
+
import dimvexa
|
|
8
|
+
|
|
9
|
+
dimvexa.convert(10.0, "m/s", "km/h") # 36.0
|
|
10
|
+
c = dimvexa.conversion("m", "km") # parse once ...
|
|
11
|
+
c(numpy_array) # ... apply to float64 arrays, lists or floats
|
|
12
|
+
|
|
13
|
+
try:
|
|
14
|
+
dimvexa.convert(1.0, "gal", "L")
|
|
15
|
+
except dimvexa.DimvexaError as e:
|
|
16
|
+
e.code, e.candidates # 'ambiguous_symbol', ['gal_us', 'gal_imp']
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Every refusal is a `DimvexaError` (a `ValueError`) with a stable `code`, `suggestions` and
|
|
20
|
+
`candidates`. `exact=True` routes through the exact rational path, rounded once.
|
|
21
|
+
|
|
22
|
+
## Build and test
|
|
23
|
+
|
|
24
|
+
This crate is its own workspace (it needs PyO3 and NumPy from the registry; the main workspace is
|
|
25
|
+
std-only and offline). It is not part of `cargo xtask ci`.
|
|
26
|
+
|
|
27
|
+
```console
|
|
28
|
+
cd bindings/python
|
|
29
|
+
python -m venv .venv && . .venv/bin/activate
|
|
30
|
+
pip install maturin pytest numpy
|
|
31
|
+
maturin develop
|
|
32
|
+
pytest
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Wheels are `abi3` (Python 3.9+). No performance claim is made until a dated benchmark run exists
|
|
36
|
+
(`docs/benchmarking.md`).
|