Skip to content

Commit

Permalink
resolve remaining doctests, enable doctest in CI
Browse files Browse the repository at this point in the history
closes #1115
  • Loading branch information
clarkgwillison committed Jun 23, 2020
1 parent 5e3dacc commit 4b73ae4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 22 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ script:
- if [[ $PANDAS == 0 && $LINT == 0 && $DOCS == 0 ]]; then python -bb -m pytest $TEST_OPTS; fi
- if [[ $LINT == 1 ]]; then black -t py36 --check . && isort -rc -c . && flake8; fi
- if [[ $DOCS == 1 ]]; then PYTHONPATH=$PWD sphinx-build -n -j auto -b html -d build/doctrees docs build/html; fi
- if [[ $DOCS == 1 ]]; then PYTHONPATH=$PWD sphinx-build -a -j auto -b doctest -d build/doctrees docs build/doctest; fi
- if [[ $LINT == 0 && $DOCS == 0 ]]; then coverage report -m; fi

after_success:
Expand Down
2 changes: 1 addition & 1 deletion CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Pint Changelog
0.14 (unreleased)
-----------------

- Nothing changed yet.
- Started automatically testing examples in the documentation


0.13 (2020-06-17)
Expand Down
24 changes: 3 additions & 21 deletions docs/systems.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,11 @@ or more drastically to:
>>> '{:.3f}'.format(q.to_base_units())
'1.094 yard / second'

.. warning:: In versions previous to 0.7 ``to_base_units`` returns quantities in the
.. warning:: In versions previous to 0.7, ``to_base_units()`` returns quantities in the
units of the definition files (which are called root units). For the definition file
bundled with pint this is meter/gram/second. To get back this behaviour use ``to_root_units``,
bundled with pint this is meter/gram/second. To get back this behaviour use ``to_root_units()``,
set ``ureg.system = None``


You can also use system to narrow down the list of compatible units:

.. doctest::

>>> ureg.default_system = 'mks'
>>> ureg.get_compatible_units('meter')
frozenset({<Unit('light_year')>, <Unit('angstrom')>})

or for imperial units:

.. doctest::

>>> ureg.default_system = 'imperial'
>>> ureg.get_compatible_units('meter')
frozenset({<Unit('thou')>, <Unit('league')>, <Unit('nautical_mile')>, <Unit('inch')>, <Unit('mile')>, <Unit('yard')>, <Unit('foot')>})


You can check which unit systems are available:

.. doctest::
Expand All @@ -71,7 +53,7 @@ Or which units are available within a particular system:
.. doctest::

>>> dir(ureg.sys.imperial)
['UK_hundredweight', 'UK_ton', 'acre_foot', 'cubic_foot', 'cubic_inch', 'cubic_yard', 'drachm', 'foot', 'grain', 'imperial_barrel', 'imperial_bushel', 'imperial_cup', 'imperial_fluid_drachm', 'imperial_fluid_ounce', 'imperial_gallon', 'imperial_gill', 'imperial_peck', 'imperial_pint', 'imperial_quart', 'inch', 'long_hunderweight', 'long_ton', 'mile', 'ounce', 'pound', 'quarter', 'short_hunderdweight', 'short_ton', 'square_foot', 'square_inch', 'square_mile', 'square_yard', 'stone', 'yard']
['UK_force_ton', 'UK_hundredweight', ... 'cubic_foot', 'cubic_inch', ... 'thou', 'ton', 'yard']

Notice that this give you the opportunity to choose within units with colliding names:

Expand Down

0 comments on commit 4b73ae4

Please sign in to comment.