lmmentel / mendeleev

A python package for accessing various properties of elements, ions and isotopes in the periodic table of elements.
https://mendeleev.readthedocs.io
MIT License
208 stars 38 forks source link

`Isotope.half_life_unit` values are ambiguous #157

Closed lmmentel closed 1 month ago

lmmentel commented 1 month ago

Describe the bug

Units from Isotope.half_life_unit are not standardize and therefore are incorrectly parsed when using tools like pint.

To Reproduce

Steps to reproduce the behavior:

  1. install pint
from pint import UnitRegistry
from mendeleev.db import get_session, get_engine
from mendeleev.models import Isotope

ureg = UnitRegistry()

session.query(Isotope.half_life_unit).distinct().all()
session = get_session()
session.query(Isotope.half_life_unit).distinct().all()
units = session.query(Isotope.half_life_unit).distinct().all()
for unit in [u for u, in units]:
     try:
         print(unit, ureg(unit))
     except:
         print(f"Coundn't parse:' {unit}'") 
None 1 dimensionless
Coundn't parse:' y'
ys 1 yoctosecond
ms 1 millisecond
zs 1 zeptosecond
d 1 day
as 1 attosecond
Coundn't parse:' My'
s 1 second
m 1 meter
Coundn't parse:' ky'
ps 1 picosecond
h 1 hour
Gy 1 gray
Coundn't parse:' Ey'
Coundn't parse:' Py'
ns 1 nanosecond
us 1 microsecond
Coundn't parse:' Zy'
Coundn't parse:' Ty'
Coundn't parse:' Yy'

Expected behavior

Units should be compatible with the unit registry from pint.

Specification