Python units/quantities packages

Business > IT development > Frameworks
2021-12-14 21:40:54
There are far too many different packages for unit conversion / quantities calculations in Python. Developers should cooperate on one package instead of fragmenting development across many different ones. This documents which features are supported by each package.
WebsitePyPI DLs/monthGitHub StarsUsed byBuilt-in unitsBuilt-in constantsArbitrary prefixesnp scalar arraynp object arrayDecimalFractionUncertaintiesstringabsolute °CdBSyntaxComments
scipy.constants 50Yes 400 in CODATANo- no unit objects- no unit objects- no unit objects- no unit objects- no unit objects- no unit objectsNoNoconstants.c == 299792458.0Just tables of numerical constants; unit-aware calculations not supported. scipy.constants.physical_constants specifies units as strings and uncertainties. Could be used to supply other packages with coefficients.
sympy.physics.units 200?Yes- u.mega*u.meter but not u.megameterNoYes array([1, 2, 3])*u.m- converts to sympy- converts to sympycm = u.m/100
astropy.units * u.meter / (32.0 * u.second)
Pint Mm, GV, etc.Yes array([1,2,3])*ureg.m or ureg.m*array([1,2,3])No ValueErrorYesYesYes built-inYesYesNoV = 1***3
unyt 101Yes 33Yes km4*m + 3*cm - 5*ft + 6*yard
Quantitieshttp://python-quantities.readthedocs.org3917147231Yes array([1,2,3]) * pq.JNo
numericalunits issues, random set of units = not deterministic, need to do calculations twice to confirm they are being done correctly
SciMath Units built-in
Buckingham 53NoYesV = Number(1,dims='decimeter^3')Single file
natu 40YesYes m*array([1, 2, 3])Yes array([1, 2, 3])*mNoNoYesNoYesYesV = 1*dm**3weird format for dB, Hz != 1/s, "pre-release state"
udunitspy wrapper for UDUNITS2
ScientificPython PhysicalQuantities
  • 2016-03-06 19:38:38
    2021-12-14 21:40:54
  • Frameworks
  • this is an excerpt
  • Public
  • Creative Commons License CC-BY-SA 3.0 / GNU FDL
    Manage backups


  • voted for this Comparison (Like)
    Posted 2020-05-06 18:58:19 by Alexis
  • voted for this Comparison (Like)
    Posted 2020-05-06 00:36:47 by wkpk2x62vz

Leave a comment

Register Sign in