{"id":20548684,"url":"https://github.com/kenkundert/quantiphy","last_synced_at":"2025-08-20T04:32:55.668Z","repository":{"id":39170072,"uuid":"71434609","full_name":"KenKundert/quantiphy","owner":"KenKundert","description":"Physical quantities","archived":false,"fork":false,"pushed_at":"2024-04-27T23:21:35.000Z","size":1576,"stargazers_count":62,"open_issues_count":1,"forks_count":5,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-05-16T02:25:08.422Z","etag":null,"topics":["python","quantiphy","quantities","si-prefixes","si-units","unit-conversions","units"],"latest_commit_sha":null,"homepage":"https://quantiphy.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KenKundert.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-20T07:02:48.000Z","updated_at":"2024-06-05T01:53:54.359Z","dependencies_parsed_at":"2024-01-16T09:00:59.054Z","dependency_job_id":"576f68ff-2deb-4d2c-8fd4-e5a5fa1f7101","html_url":"https://github.com/KenKundert/quantiphy","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KenKundert%2Fquantiphy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KenKundert%2Fquantiphy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KenKundert%2Fquantiphy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KenKundert%2Fquantiphy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KenKundert","download_url":"https://codeload.github.com/KenKundert/quantiphy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230394228,"owners_count":18218707,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","quantiphy","quantities","si-prefixes","si-units","unit-conversions","units"],"created_at":"2024-11-16T02:14:17.126Z","updated_at":"2025-08-20T04:32:55.654Z","avatar_url":"https://github.com/KenKundert.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"QuantiPhy — Physical Quantities\n===============================\n\n|downloads| |build status| |coverage| |rtd status| |pypi version| |anaconda version| |python version|\n\n| Author: Ken Kundert\n| Version: 2.20.2\n| Released: 2025-03-08\n|\n\n\nWhat?\n-----\n\n*QuantiPhy* is a Python library that offers support for physical quantities.  \nA quantity is the pairing of a number and a unit of measure that indicates the \namount of some measurable thing.  *QuantiPhy* provides quantity objects that \nkeep the units with the number, making it easy to share them as single object.  \nThey subclass float and so can be used anywhere a real number is appropriate.\n\n\nWhy?\n----\n\n*QuantiPhy* naturally supports SI scale factors, which are widely used in \nscience and engineering. SI scale factors make it possible to cleanly represent \nboth very large and very small quantities in a form that is both easy to read \nand write.  While generally better for humans, no general programming language \nprovides direct support for reading or writing quantities with SI scale factors, \nmaking it difficult to write numerical software that communicates effectively \nwith people.  *QuantiPhy* addresses this deficiency, making it natural and \nsimple to both input and output physical quantities.\n\n\nFeatures\n--------\n\n- Flexibly reads amounts with units and SI scale factors.\n- Quantities subclass the *float* class and so can be used as conventional \n  numbers.\n- Generally includes the units when printing or converting to strings and by \n  default employs SI scale factors.\n- Flexible unit conversion and scaling is supported to make it easy to convert \n  to or from any required form.\n- Supports the binary scale factors (*Ki*, *Mi*, etc.) along with the normal SI \n  scale factors (*k*, *M*, etc.).\n- When a quantity is created from a string, the actual digits specified can be \n  used in any output, eliminating any loss of precision.\n\n\nAlternatives\n------------\n\nThere are a considerable number of Python packages dedicated to units and \nquantities (`alternatives \u003chttps://kdavies4.github.io/natu/seealso.html\u003e`_).  \nHowever, as a rule, they focus on the units rather than the scale factors. In \nparticular, they build a system of units that you are expected to use throughout \nyour calculations.  These packages demand a high level of commitment from their \nusers and in turn provide unit consistency and built-in unit conversions.\n\nIn contrast, *QuantiPhy* treats units basically as documentation.  They are \nsimply strings that are attached to quantities largely so they can be presented \nto the user when the values are printed. As such, *QuantiPhy* is a light-weight \npackage that demands little from the user.  It is used when inputting and \noutputting values, and then only when it provides value.  As a result, it \nprovides a simplicity in use that cannot be matched by the other packages.\n\nIn addition, these alternative packages generally build their unit systems upon \nthe `SI base units \u003chttps://en.wikipedia.org/wiki/SI_base_unit\u003e`_, which tends \nto restrict usage to physical quantities with static conversion factors.  They \nare less suited to non-physical quantities or conversion factors that change \ndynamically, such as with currencies.  *QuantiPhy* gracefully handles all of \nthese cases.\n\n\nQuick Start\n-----------\n\nYou can find the documentation on `ReadTheDocs\n\u003chttps://quantiphy.readthedocs.io\u003e`_.  Install with::\n\n   pip3 install quantiphy\n\nRequires Python 3.6 or newer.  If you using an earlier version of Python,\ninstall version 2.10 of *QuantiPhy*.\n\nYou can find the full documentation `here \u003chttps://quantiphy.readthedocs.io\u003e`_.\n\nYou use *Quantity* to convert numbers and units in various forms to quantities:\n\n.. code-block:: python\n\n   \u003e\u003e\u003e from quantiphy import Quantity\n\n   \u003e\u003e\u003e Tclk = Quantity(10e-9, 's')\n   \u003e\u003e\u003e print(Tclk)\n   10 ns\n\n   \u003e\u003e\u003e Fhy = Quantity('1420.405751786 MHz')\n   \u003e\u003e\u003e print(Fhy)\n   1.4204 GHz\n\n   \u003e\u003e\u003e Rsense = Quantity('1e-4Ω')\n   \u003e\u003e\u003e print(Rsense)\n   100 uΩ\n\n   \u003e\u003e\u003e cost = Quantity('$11_200_000')\n   \u003e\u003e\u003e print(cost)\n   $11.2M\n\n   \u003e\u003e\u003e Tboil = Quantity('212 °F', scale='°C')\n   \u003e\u003e\u003e print(Tboil)\n   100 °C\n\nOnce you have a quantity, there are a variety of ways of accessing aspects of \nthe quantity:\n\n.. code-block:: python\n\n   \u003e\u003e\u003e Tclk.real\n   1e-08\n\n   \u003e\u003e\u003e float(Fhy)\n   1420405751.786\n\n   \u003e\u003e\u003e 2*cost\n   22400000.0\n\n   \u003e\u003e\u003e Rsense.units\n   'Ω'\n\n   \u003e\u003e\u003e str(Tboil)\n   '100 °C'\n\nYou can use the *render* method to flexibly convert the quantity to a string:\n\n.. code-block:: python\n\n   \u003e\u003e\u003e Tclk.render()\n   '10 ns'\n\n   \u003e\u003e\u003e Tclk.render(show_units=False)\n   '10n'\n\n   \u003e\u003e\u003e Tclk.render(form='eng', show_units=False)\n   '10e-9'\n\n   \u003e\u003e\u003e Fhy.render(prec=8)\n   '1.42040575 GHz'\n\n   \u003e\u003e\u003e Tboil.render(scale='°F')\n   '212 °F'\n\nThe *fixed* method is a variant that specializes in rendering numbers without \nscale factors or exponents:\n\n.. code-block:: python\n\n   \u003e\u003e\u003e cost.fixed(prec=2, show_commas=True, strip_zeros=False)\n   '$11,200,000.00'\n\nYou can use the string format method or the new format strings to flexibly \nincorporate quantity values into strings:\n\n.. code-block:: python\n\n   \u003e\u003e\u003e f'{Fhy}'\n   '1.4204 GHz'\n\n   \u003e\u003e\u003e f'{Fhy:.6}'\n   '1.420406 GHz'\n\n   \u003e\u003e\u003e f'❬{Fhy:\u003c15.6}❭'\n   '❬1.420406 GHz   ❭'\n\n   \u003e\u003e\u003e f'❬{Fhy:\u003e15.6}❭'\n   '❬   1.420406 GHz❭'\n\n   \u003e\u003e\u003e f'{cost:#,.2P}'\n   '$11,200,000.00'\n\n   \u003e\u003e\u003e f'Boiling point of water: {Tboil:s}'\n   'Boiling point of water: 100 °C'\n\n   \u003e\u003e\u003e f'Boiling point of water: {Tboil:s°F}'\n   'Boiling point of water: 212 °F'\n\n*QuantiPhy* has many more features and capabilities. For more information, view \nthe `documentation \u003chttps://quantiphy.readthedocs.io\u003e`_.\n\n\n.. |downloads| image:: https://pepy.tech/badge/quantiphy/month\n    :target: https://pepy.tech/project/quantiphy\n\n.. |rtd status| image:: https://img.shields.io/readthedocs/quantiphy.svg\n   :target: https://quantiphy.readthedocs.io/en/latest/?badge=latest\n\n.. |build status| image:: https://github.com/KenKundert/quantiphy/actions/workflows/build.yaml/badge.svg\n    :target: https://github.com/KenKundert/quantiphy/actions/workflows/build.yaml\n\n.. |coverage| image:: https://coveralls.io/repos/github/KenKundert/quantiphy/badge.svg?branch=master\n    :target: https://coveralls.io/github/KenKundert/quantiphy?branch=master\n\n.. |pypi version| image:: https://img.shields.io/pypi/v/quantiphy.svg\n    :target: https://pypi.python.org/pypi/quantiphy\n\n.. |anaconda version| image:: https://anaconda.org/conda-forge/quantiphy/badges/version.svg\n    :target: https://anaconda.org/conda-forge/quantiphy\n\n.. |python version| image:: https://img.shields.io/pypi/pyversions/quantiphy.svg\n    :target: https://pypi.python.org/pypi/quantiphy/\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkenkundert%2Fquantiphy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkenkundert%2Fquantiphy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkenkundert%2Fquantiphy/lists"}