https://github.com/uibcdf/pyunitwizard
Assistant to work with physical quantities, units, and python libraries such as Pint, openmm.unit or unyt.
https://github.com/uibcdf/pyunitwizard
python quantities
Last synced: about 7 hours ago
JSON representation
Assistant to work with physical quantities, units, and python libraries such as Pint, openmm.unit or unyt.
- Host: GitHub
- URL: https://github.com/uibcdf/pyunitwizard
- Owner: uibcdf
- License: other
- Created: 2021-01-28T05:49:22.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-06-21T21:31:25.000Z (about 1 year ago)
- Last Synced: 2024-06-23T08:32:03.779Z (about 1 year ago)
- Topics: python, quantities
- Language: Python
- Homepage: https://www.uibcdf.org/PyUnitWizard/
- Size: 5.97 MB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# PyUnitWizard
[](https://opensource.org/licenses/MIT)
[](https://www.python.org/downloads/)
[](https://github.com/uibcdf/PyUnitWizard/actions/workflows/sphinx_docs_to_gh_pages.yaml)
[](https://github.com/uibcdf/PyUnitWizard/actions/workflows/CI.yaml)
[](https://codecov.io/github/uibcdf/PyUnitWizard)
[](https://conda.anaconda.org/uibcdf/pyunitwizard)
[](https://github.com/uibcdf/PyUnitWizard/actions/workflows/install_ubuntu_latest.yaml)
[](https://github.com/uibcdf/PyUnitWizard/actions/workflows/install_macos_latest.yaml)There are several Python libraries to work with physical quantities in the
market, such as pint, unyt or openmm.unit. Imagine that your project or
workflow requires the interaction with more than one of these tools, or that
you are not sure if you will work with a different quantities library in the
future. Wouldn't having a unique API to work with different forms of physical
quantities be a relief? PyUnitWizard just does that. It is the wizard you need
in your code to change the form of your quantities with no effort.## Example
```ipython
In [1]: import pyunitwizard as puwIn [2]: puw.configure.load_libraries(['pint', 'openmm.unit'])
...: puw.configure.set_default_form('pint')
...: puw.configure.set_standard_units(['nm', 'ps', 'kcal', 'mole'])
...:In [3]: q = puw.quantity(2.5, 'nanometers/picoseconds')
In [4]: puw.get_form(q)
Out[4]: 'pint'In [5]: puw.get_value(q)
Out[5]: 2.5In [6]: puw.get_unit(q)
Out[6]:In [7]: puw.dimensionality(q)
Out[7]: {'[L]': 1, '[M]': 0, '[T]': -1, '[K]': 0, '[mol]': 0, '[A]': 0, '[Cd]': 0}In [8]: q2 = puw.convert(q, to_unit='angstroms/femtoseconds', to_form='openmm.unit')
In [9]: print(q2)
0.025000000000000005 A/fsIn [10]: puw.get_form(q2)
Out[10]: 'openmm.unit'In [11]: puw.compatibility(q, q2)
Out[11]: TrueIn [12]: q3 = puw.standardize(q2)
In [13]: print('q3 is now a {} quantity expressed in {}.'.format(puw.get_form(q3), puw.get_unit(q3)))
q3 is now a pint quantity expressed in nanometer / picosecond.
```## Units Python libraries
- [openmm.unit](https://github.com/openmm/openmm/tree/master/wrappers/python/simtk/unit)
- [Pint](https://pint.readthedocs.io/en/stable/)
- [unyt](https://unyt.readthedocs.io/en/stable/)## License
This project is under an MIT License. [A copy of the license text is included in this repository](LICENSE).
### Copyright
Copyright (c) 2021-2022 [The Mexico Children's Hospital Federico Gómez](http://himfg.com.mx/), [its Unit of Research on Computational
Biology and Drug Design](http://uibcdf.org), and [authors](https://github.com/uibcdf/OpenExplorer/graphs/contributors).## Acknowledgements
Project based on the [Computational Molecular Science Python Cookiecutter](https://github.com/molssi/cookiecutter-cms) version 1.5.
## Contributors
A complete list of contributors can be found checking [the insights section of this
repository](https://github.com/uibcdf/OpenExplorer/graphs/contributors).The main project authors and contributors are:
- Daniel Ibarrola Sánchez
- Liliana M. Moreno Vargas
- Diego Prada Gracia