Skip to content

Commit

Permalink
tweak the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Ken Kundert authored and Ken Kundert committed Feb 8, 2022
1 parent 04ac79e commit 26c545b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 17 deletions.
28 changes: 18 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ science and engineering. SI scale factors make it possible to cleanly represent
both very large and very small quantities in a form that is both easy to read
and write. While generally better for humans, no general programming language
provides direct support for reading or writing quantities with SI scale factors,
making it difficult to write software that communicates effectively with humans.
*QuantiPhy* addresses this deficiency, making it natural and simple to both
input and output physical quantities.
making it difficult to write numerical software that communicates effectively
with people. *QuantiPhy* addresses this deficiency, making it natural and
simple to both input and output physical quantities.


Features
Expand All @@ -72,13 +72,21 @@ quantities (`alternatives <https://kdavies4.github.io/natu/seealso.html>`_).
However, as a rule, they focus on the units rather than the scale factors. In
particular, they build a system of units that you are expected to use throughout
your calculations. These packages demand a high level of commitment from their
users and in turn provide unit consistency and built-in unit conversions. In
contrast, *QuantiPhy* treats units basically as documentation. They are simply
strings that are attached to quantities largely so they can be presented to the
user when the values are printed. As such, *QuantiPhy* is a light-weight package
that demands little from the user. It is used when inputting and outputting
values, and then only when it provides value. As a result, it provides
a simplicity in use that cannot be matched by the other packages.
users and in turn provide unit consistency and built-in unit conversions.

In contrast, *QuantiPhy* treats units basically as documentation. They are
simply strings that are attached to quantities largely so they can be presented
to the user when the values are printed. As such, *QuantiPhy* is a light-weight
package that demands little from the user. It is used when inputting and
outputting values, and then only when it provides value. As a result, it
provides a simplicity in use that cannot be matched by the other packages.

In addition, these alternative packages generally build their unit systems upon
the `SI base units <https://en.wikipedia.org/wiki/SI_base_unit>`_, which tends
to restrict usage to physical quantities with static conversion factors. They
are less suited to non-physical quantities or conversion factors that change
dynamically, such as with currencies. *QuantiPhy* gracefully handles all of
these cases.


Quick Start
Expand Down
27 changes: 20 additions & 7 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ Features
- Flexible unit conversion and scaling is supported to make it easy to convert
to or from any required form.
- Provides a small but extensible collection of physical constants.
- Supports the binary scale factors (*Ki*, *Mi*, etc.) along with the normal SI
scale factors (*k*, *M*, etc.).


Alternatives
Expand Down Expand Up @@ -86,8 +88,8 @@ Install with::

pip3 install quantiphy

Requires Python3.5 or newer. If you using an earlier version of Python, install
version 2.10 of *QuantiPhy*.
Requires Python 3.6 or newer. If you using an earlier version of Python,
install version 2.10 of *QuantiPhy*.

You use *Quantity* to convert numbers and units in various forms to quantities:

Expand Down Expand Up @@ -135,7 +137,7 @@ the quantity:
>>> str(Tboil)
'100 °C'
You can use the render method to flexibly convert the quantity to a string:
You can use the *render* method to flexibly convert the quantity to a string:

.. code-block:: python
Expand All @@ -154,6 +156,14 @@ You can use the render method to flexibly convert the quantity to a string:
>>> Tboil.render(scale='°F')
'212 °F'
The *fixed* method is a variant that specializes in rendering numbers without
scale factors or exponents:

.. code-block:: python
>>> cost.fixed(prec=2, show_commas=True, strip_zeros=False)
'$11,200,000.00'
You can use the string format method or the new format strings to flexibly
incorporate quantity values into strings:

Expand All @@ -165,11 +175,14 @@ incorporate quantity values into strings:
>>> f'{Fhy:.6}'
'1.420406 GHz'
>>> f'«{Fhy:<15.6}»'
'«1.420406 GHz »'
>>> f'{Fhy:<15.6}'
'❬1.420406 GHz ❭'
>>> f'{Fhy:>15.6}'
'❬ 1.420406 GHz❭'
>>> f'«{Fhy:>15.6}»'
'« 1.420406 GHz»'
>>> f'{cost:#,.2P}'
'$11,200,000.00'
>>> f'Boiling point of water: {Tboil:s}'
'Boiling point of water: 100 °C'
Expand Down

0 comments on commit 26c545b

Please sign in to comment.