Unit Conversion in Python

前端 未结 9 1369
清歌不尽
清歌不尽 2020-12-07 11:05

I\'m working on a project that lets users track different data types over time. Part of the base idea is that a user should be able to enter data using any units that they n

相关标签:
9条回答
  • 2020-12-07 12:07

    It looks like another package has come out for doing this as well, written by Massimo DiPierro of web2py fame, called Buckingham.

    Also of note, Brian has had something like this for some time.

    0 讨论(0)
  • I am surprised that nobody mentioned SymPy yet. SymPy is a mature and well-maintained symbolic mathematics library for Python that is moreover a NumFOCUS-sponsored project.

    It has a Physics module with many useful classes and functions for "solving problems in physics". Most relevant for you, it has a Unit sub-module that contains everything you need, I think; just read the excellent documentation.

    0 讨论(0)
  • 2020-12-07 12:10

    There is another package called unyt from the yt-project. The authors of unyt acknowledge the existence of Pint and astropy.units. Conversions from and to these other packages is supported.

    The selling point of unyt is speed. It is faster than the other two. The unit packages are compared in several benchmarks in this paper.

    The benchmarks are disappointing for anyone obsessed with performance. :-( The slowdown of calculations with any of these unit systems is large. The slowdown factor is 6-10 for arrays with 1000 entries (worse for smaller arrays).

    Disclaimer: I am not affiliated with unyt, I just want to share what I learned about unit systems.

    0 讨论(0)
提交回复
热议问题