Metadata-Version: 2.4
Name: unilyte
Version: 0.1.0a0
License-File: LICENSE
Summary: Parse and render battery electrolyte formulation shorthand
License-Expression: MIT
Requires-Python: >=3.9
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM

# unilyte

An easy, unified, and unambiguous way to write electrolytes.

Parses and validates battery electrolyte formulation shorthand (e.g. `1M LiPF6 in EC:EMC 3:7wt + 1wt% LiDFOB`) into an unambiguous, JSON-serializable canonical form, and renders it back to shorthand text without losing information.

✅ A perfect unilyte string
"1M LiPF6 in EC:EMC 3:7wt" -> "1M LiPF6 in EC:EMC 3:7wt"

✅ Messy strings get normalized
"  1M LiPF6 in (EC:EMC  3:7weight)   + 1w%  LiDFOB" -> ✅ cleaned up "1M LiPF6 in EC:EMC 3:7wt + 1wt% LiDFOB"

❌ Missing units not allowed
"1M LiPF6 in EC:EMC 3:7" ->  errors

❌ Ambiguous quantities not allowed
"1M LiPF6 in EC:EMC 3:7wt + EC:DMC 3:7wt" ->  errors

Built in Rust with a CLI and Python bindings.


## For developers

```bash
git clone https://github.com/g-kimbell/unilyte
cd unilyte
```

To build the `unilyte' `[[bin]]` Rust CLI, you must first build with cargo. Use as is or copy to the scripts folder so it is bundled in the Python wheel.

If you skip this step and just pip install, the Python bindings still work, there is just no CLI.

```bash
cargo build --release --bin unilyte
cp target/release/unilyte.exe unilyte.data/scripts/unilyte.exe  # no .exe on Linux/macOS
pip install .  # or: pip install -e .   /   maturin develop --release
```

Re-run the first two lines whenever you change `src/bin/unilyte.rs` (or its dependencies) before reinstalling — it is not rebuilt automatically by `pip install`.

```bash
cargo test                    # Rust test suite
uv run --with maturin maturin develop --release && python -m pytest python_tests/   # Python bindings
```

**Warning:** because the unilyte CLI is copied manually, `maturin develop` doesn't check if it has changed. If Cargo reports everything "Fresh" (e.g. because you already ran `cargo build --release --bin unilyte` separately), `maturin develop` can silently skip reinstalling the wheel entirely, leaving a stale CLI binary. To avoid this, force a reinstall:

```bash
uv pip install . --reinstall
```

`scripts/emmo_terms.py` regenerates `src/registry_data.json` (the built-in salt/solvent registry) from the [EMMO chemical-substance ontology](https://github.com/emmo-repo/domain-chemical-substance):

```bash
uv run --with rdflib scripts/emmo_terms.py --export src/registry_data.json
```

