Mirror of lifefrom-units 1.1.0 (Zenodo doi:10.5281/zenodo.24568184, GitHub caraulani/lifefrom-units)
afecedd verified |
Download python/README.md from lifefrom/lifefrom-units: direct link, hf CLI and curl.
- Browser
- Download file 1.17 kB
-
https://huggingface.co/datasets/lifefrom/lifefrom-units/resolve/main/python/README.md
- Command line
-
hf download hf://datasets/lifefrom/lifefrom-units/python/README.md
-
curl -L -o README.md https://huggingface.co/datasets/lifefrom/lifefrom-units/resolve/main/python/README.md
1.17 kB
lifefrom-units (Python)
Normalise clinical lab unit spellings and convert lab values with sourced, analyte-specific factors. Zero runtime dependencies. Python 3.9 or newer. Distribution lifefrom-units, import lifefrom_units, CLI lifefrom-units.
from lifefrom_units import convert, convert_result, normalize_unit, same_unit, explain
normalize_unit("mcg/l") # 'µg/L'
convert("5,4", "mmol/L", "mg/dL", analyte="glucose") # 97.2864
convert_result("<5", "mg/dL", "mmol/L", analyte="glucose") # comparator '<' kept
same_unit("K/µL", "10^9/L") # True
convert(10, "µIU/mL", "pmol/L", analyte="insulin", factor=6) # your factor; recorded by explain()
explain("mg/dL", "nmol/L", analyte="lipoprotein-a") # raises ForbiddenConversionError
convert("7,5", "mil/mm3", "10^9/L", locale="es") # 7.5: in Spanish "mil" is thousand
convert("7,5", "mil/mm3", "10^9/L") # raises AmbiguousUnitError (million in English)
Sources, checks and limitations are described in the repository README and METHODS: https://github.com/caraulani/lifefrom-units