To install, just:
$ easy_install unties
$ pip install unties
### What is this repository for?
* Another units-handling package
### How do I get set up?
* See install directions above
* No configuration options
* No dependencies
* To run tests: `python setup.py test`
To use, import the Units class. I like to shorthand it as `_`, after the style
of TI calculators:
>>> import unties as _
Or, especially if you're just playing in a python console, feel free to wildcard
>>> from unties import *
And you instantly have access to a ton of units and constants
Convert 11.5 'ft' to 'inch'
>>> 11.5 * ft.units_of(inch)
138.00000000000003 * inch
As you can see from the examples, floating-point math is hard
You can call units with another unit as the argument as shorthand for
conversion. So you can do:
>>> 11.5 * ft(inch)
138.00000000000003 * inch
Conversion will *not* raise an error if the units groups have different
dimensions; instead, basic units will be used to make up the difference, without
affecting the value:
17.6 * inch / s
178.1073544430114 * cal / s
43559.99999999999 * ft**2
Multiple units should be grouped:
>>> (yd / hr)(mm / s)
0.254 * mm / s
or else strange things happen:
>>> yd / hr(mm / s)
2.7777777777777776e-07 * m * yd / (mm * s)
Please note, though, that conversion never changes the value of a measurement.
In the previous example, `2.7777777777777776e-07 * m * yd / (mm * s) == yd / hr`
If you're ever unsure what a unit symbol represents, just type it into the
console, and the unit's name and quantity will be shown:
1.0 * amu # Atomic mass unit [mass]
If you've done some calculations and want to check what quantity your new unit
group measures, use the `quantity()` method:
>>> (3 * hp / mmHg).quantity()
### Contribution guidelines
* Contributions are welcome. Just make a pull request.
* Use [pep8](https://pypi.python.org/pypi/pep8) to lint your Python code.
* Write new tests for any new features
The MIT License (MIT)
Copyright (c) 2016 Spencer Christiansen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
All Authors and Contributors:
TODO: Brief introduction on what you do with files - including link to relevant help section.