Dimension Checked Quantity Converter
Convert physical quantities with exact rational arithmetic and reject incompatible dimensions.
Version: 1.0.0. License: MIT. Status: tested reference baseline; no comparative ranking is claimed.
Contract
Accept finite decimal or rational strings supported by fractions.Fraction. Supported length units: m, cm, mm, in, ft; mass: kg, g, lb; time: s, min, h; absolute temperature: K, degC, degF. Use exact defined conversion factors. Return a reduced numerator and denominator as strings. Reject incompatible dimensions and temperatures below absolute zero.
The exact required input fields and types are in input.schema.json. Extra fields are rejected at declared object boundaries. JSON duplicate keys and non-finite numbers are rejected by the CLI. Input strings are case-sensitive unless stated otherwise. Array order is preserved unless the contract specifies sorting.
Use
Unpack the ZIP, enter its directory, and run:
python3 baseline.py < example.input.json
python3 -m unittest -v
Python 3.10 or newer, standard library only. The reference implementation exposes run(input_dict) and accepts one JSON object on standard input. Success returns {"ok": true, "result": ...} with exit code 0. Invalid input returns {"ok": false, "error": "..."} with exit code 1. example.output.json contains the result without the CLI envelope. Import callers receive exceptions for invalid input.
Example input
{
"value": "1",
"from_unit": "in",
"to_unit": "mm"
}
Example result
{
"numerator": "127",
"denominator": "5",
"unit": "mm",
"dimension": "length"
}
Boundaries
Temperature values are absolute readings, not temperature differences. No currency, calendar durations, compound units, or ambiguous unit aliases are accepted. Callers choose decimal precision when formatting the exact result. Unit constants follow SI and NIST definitions.
This package performs no network calls, executes no submitted commands, and writes no user files. Host applications own authorization, resource budgets, and persistence. Example values are fixtures, not recommended policies or limits.
Acceptance and provenance
cases.json records named expected results and rejection cases. test_baseline.py runs those cases and checks the command-line contract. manifest.json records file digests. The specification, implementation, and evidence are separate files so a replacement implementation can target the same contract.
Original code and examples generated for this Arcomm collection. No third-party code is bundled. Read LICENSE for reuse terms.
References
Download
SHA-256: 037327a9bc33918c07e24439c53bc0c46363a36813259f0f9d55b1a871833945
Size: 6962 bytes.