{ "info": { "author": "Aran Donohue", "author_email": "aran@arandonohue.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Intended Audience :: Science/Research", "Intended Audience :: System Administrators", "License :: OSI Approved :: Python Software Foundation License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Scientific/Engineering", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Utilities" ], "description": "Provides support for quantities and units, which strictly disallow\ninvalid operations between incompatible quantities. For example, we cannot add\n2 metres to 5 seconds, because this doesn't make sense.\n\nWhy?\n\nFrom Wikipedia:\n\nThe Mars Climate Orbiter was intended to enter orbit at an altitude of\n140-150 km (460,000-500,000 ft.) above Mars. However, a navigation error\ncaused the spacecraft to reach as low as 57 km (190,000 ft.). The spacecraft\nwas destroyed by atmospheric stresses and friction at this low altitude. The\nnavigation error arose because a NASA subcontractor (Lockheed Martin) used\nImperial units (pound-seconds) instead of the metric system.\n\nInstallation\n============\n\nThis module is distributed via PyPI. So, you can do::\n\n pip install units\n\nor::\n\n easy_install units\n\nor, you can download a bundle yourself at http://pypi.python.org/pypi/units/\n\nIf you want the latest::\n\n pip install -e hg+https://bitbucket.org/adonohue/units/#egg=units\n\n\nHow to Use\n==========\n\nMake Quantities\n---------------\n\nUnits are objects that you use to make quantities::\n\n >>> from units import unit\n >>> metre = unit('m')\n >>> print(metre(7) + metre(11))\n 18.00 m\n\nYou can mix and match these quantities in some ways::\n\n >>> from units import unit\n >>> metre = unit('m')\n >>> second = unit('s')\n >>> print(metre(10) / second(2))\n 5.00 m / s\n >>> print(metre(10) ** 3)\n 1000.00 m * m * m\n\nBut if you make a mistake, you get a safety net::\n\n >>> from units import unit\n >>> try:\n ... unit('m')(5) + unit('s')(5)\n ... except units.exception.IncompatibleUnitsError:\n ... print('Got an error!')\n Got an error!\n\nMake Your Own Units\n-------------------\nBefore you start making your own units, you should check out the units that\nyou get for free::\n\n >>> import units.predefined\n >>> units.predefined.define_units()\n\nIt includes all the official SI units, some units for measuring time such as\ndays and weeks, units for volumes like cups, gallons and litres, imperial\nunits and more.\n\nYou've already seen how to make your own simple units. You call\nthe unit function and give it a string::\n\n >>> from units import unit\n >>> blog = unit('blog')\n >>> print(blog(3))\n 3.00 blog\n\nThese units are automatically incompatible with other units.\n\nYou can combine units with multiplication and division to make new units::\n\n >>> from units import unit\n >>> blogs_per_network = unit('blog') / unit('network')\n >>> print(blogs_per_network(2.34))\n 2.34 blog / network\n\nThere's a built-in shortcut for making new units that are scalar multiples\nof other units::\n\n >>> from units import unit, scaled_unit\n >>> sickle = scaled_unit('sickle', 'knut', 29)\n >>> galleon = scaled_unit('galleon', 'sickle', 17)\n >>> knut = unit('knut')\n >>> galleon(3.0) + sickle(1.0) - knut(25.0) == knut(1483)\n True\n\nThere's also a shortcut for giving names to slightly more complicated units::\n\n >>> from units import unit, named_unit\n >>> from units.predefined import define_units\n >>> define_units()\n >>> twp = named_unit('tweetpack', ['tweet', 'meme'], ['day'], 5)\n >>> # A tweetpack is 5 tweetmemes per day\n >>> print(twp(2))\n 2.00 tweetpack\n >>> tweet, meme, day = [unit(x) for x in ['tweet', 'meme', 'day']]\n >>> print(twp(5) - (tweet(5) * meme(4) / day(2)))\n 3.00 tweetpack\n\nIf two units are compatible, you can convert between them easily::\n\n >>> from units import unit\n >>> from units.predefined import define_units\n >>> define_units()\n >>> furlongs_per_fortnight = unit('fur') / unit('fortnight')\n >>> kph = unit('km') / unit('h')\n >>> print(furlongs_per_fortnight(kph(100)))\n 167024.58 fur / fortnight\n\nYou can also use lower-level constructors to make your own units and\nquantities. The ways shown above are easier, though.\n\nWarnings\n--------\n\nThis module doesn't solve problems with numerical accuracy or\nfloating point conversions, and Python 2 vs. 3 issues abound::\n\n from units import unit\n unit('m')(5) / unit('m')(7)\n # 0 in Python 2.x, 0.7142857142857143 in Python 3.\n\n\nMore dangerously, certain internal operations have implicit arithmetic\nthat can surprise you::\n\n from units import unit, scaled_unit\n sickle = scaled_unit('sickle', 'knut', 29)\n galleon = scaled_unit('galleon', 'sickle', 17)\n knut = unit('knut')\n galleon(3) + sickle(1) - knut(25) == galleon(3)\n # True in Python 2.x, False in Python 3\n\n\nUsing Modified Python\n---------------------\n\nIn units-enhanced Python, you can do::\n\n print(2cm / 0.5 s)\n -> 4.0 cm / s\n\nUnits-enhanced Python is a version of PyPy with built-in support\nfor units. You can find it in the unitPython directory. Essentially,\napply the supplied patches to r66797 of PyPy. If you're on a suitable\nUNIX, the included unitPython/unitPython.sh does this for you.\n\n@requires: U{Python} >= 2.5\n@since: 2009-Aug-10\n@status: under development", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://bitbucket.org/adonohue/units/", "keywords": null, "license": "Python Software Foundation License", "maintainer": null, "maintainer_email": null, "name": "units", "package_url": "https://pypi.org/project/units/", "platform": "all", "project_url": "https://pypi.org/project/units/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://bitbucket.org/adonohue/units/" }, "release_url": "https://pypi.org/project/units/0.07/", "requires_dist": null, "requires_python": null, "summary": "Python support for quantities with units", "version": "0.07" }, "last_serial": 2620020, "releases": { "0.00": [], "0.01": [ { "comment_text": "", "digests": { "md5": "a36d5151967d76806bce964f72ef378c", "sha256": "05e3194ef37ff31ce76f67ad8f96b5b05b7983a69373ec9cfb6c63561bba4373" }, "downloads": -1, "filename": "units-0.01.tar.gz", "has_sig": false, "md5_digest": "a36d5151967d76806bce964f72ef378c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15172, "upload_time": "2009-08-17T06:44:16", "url": "https://files.pythonhosted.org/packages/df/85/666d06dbbe30746048e263d9a408515d88c1a261a86673eac42042b177db/units-0.01.tar.gz" } ], "0.02": [ { "comment_text": "", "digests": { "md5": "18f6bbfc2d2454ef9cd4a49f37bd8eb5", "sha256": "dc36cbf73e394c8fad3a232d1aaba613ac7e7e004966b0dc20b0a3d54f060e23" }, "downloads": -1, "filename": "units-0.02.tar.gz", "has_sig": false, "md5_digest": "18f6bbfc2d2454ef9cd4a49f37bd8eb5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18024, "upload_time": "2009-08-17T20:59:28", "url": "https://files.pythonhosted.org/packages/3d/75/ccef0d7c4dd9135ea2ab3c4353a1c58d37db0e650b3b0a2396c92536737a/units-0.02.tar.gz" } ], "0.03": [ { "comment_text": "", "digests": { "md5": "65e785c340871a2e195436f1ecef34d7", "sha256": "dcb2f82800ddbcbbd85faf590d87ad46f48d2cea4d22f914012b3e4019121acd" }, "downloads": -1, "filename": "units-0.03.tar.gz", "has_sig": false, "md5_digest": "65e785c340871a2e195436f1ecef34d7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19991, "upload_time": "2009-10-31T22:03:41", "url": "https://files.pythonhosted.org/packages/55/91/473d0690a8d99939c9c58c7ba8f77ed0b840e4fdb44db025baa96947c42d/units-0.03.tar.gz" } ], "0.04": [ { "comment_text": "", "digests": { "md5": "064bee76e233231be1996b388d06292e", "sha256": "21bf65c1d987ed509e3e89b2afb0193bbb2266760de4cf611b2f79015d87a4ba" }, "downloads": -1, "filename": "units-0.04.tar.gz", "has_sig": false, "md5_digest": "064bee76e233231be1996b388d06292e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20194, "upload_time": "2010-08-06T09:03:14", "url": "https://files.pythonhosted.org/packages/da/ab/f9e34ace8284062d8b7340b0db4bfd43ad726fa3ce283882cd3734da4b9a/units-0.04.tar.gz" } ], "0.05": [ { "comment_text": "", "digests": { "md5": "9975e9f389f30bb1e2ee55dc8a20bdcd", "sha256": "a073bd6bab47d68259501877c2d2b032d5047aae0e9b6fc7b2b32e6cc80251d3" }, "downloads": -1, "filename": "units-0.05.tar.gz", "has_sig": false, "md5_digest": "9975e9f389f30bb1e2ee55dc8a20bdcd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18857, "upload_time": "2012-10-27T17:49:47", "url": "https://files.pythonhosted.org/packages/15/a6/4302d075adb297209e8be271b38d1a22818246c919618d701275f502c601/units-0.05.tar.gz" } ], "0.06": [ { "comment_text": "", "digests": { "md5": "e6df0e2331dace0c7bbb4ed9c8956ddf", "sha256": "63415da40801bcc73ed35d118211012cf5547b88d78690c0f26116634d93e48f" }, "downloads": -1, "filename": "units-0.06.tar.gz", "has_sig": false, "md5_digest": "e6df0e2331dace0c7bbb4ed9c8956ddf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18951, "upload_time": "2013-02-25T00:49:38", "url": "https://files.pythonhosted.org/packages/df/86/53398922ec465548f68e6c85de069dad3eae077a92a875350ec3f2e42af3/units-0.06.tar.gz" } ], "0.07": [ { "comment_text": "", "digests": { "md5": "e3c254b0881c55b22d314c763cdcfd6b", "sha256": "43eb3e073e1b11289df7b1c3f184b5b917ccad178b717b03933298716f200e14" }, "downloads": -1, "filename": "units-0.07.tar.gz", "has_sig": false, "md5_digest": "e3c254b0881c55b22d314c763cdcfd6b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19103, "upload_time": "2017-02-05T05:36:31", "url": "https://files.pythonhosted.org/packages/33/8c/76112215f71aad89ffecae90dd1e0a681ad8f750df994d4ce1275bca50a2/units-0.07.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e3c254b0881c55b22d314c763cdcfd6b", "sha256": "43eb3e073e1b11289df7b1c3f184b5b917ccad178b717b03933298716f200e14" }, "downloads": -1, "filename": "units-0.07.tar.gz", "has_sig": false, "md5_digest": "e3c254b0881c55b22d314c763cdcfd6b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19103, "upload_time": "2017-02-05T05:36:31", "url": "https://files.pythonhosted.org/packages/33/8c/76112215f71aad89ffecae90dd1e0a681ad8f750df994d4ce1275bca50a2/units-0.07.tar.gz" } ] }