commit
5f3460aa89
|
@ -7,6 +7,7 @@ env:
|
|||
- UNCERTAINTIES="N" PYTHON="3.4" NUMPY_VERSION=1.11.2
|
||||
- UNCERTAINTIES="N" PYTHON="3.5" NUMPY_VERSION=1.11.2
|
||||
- UNCERTAINTIES="Y" PYTHON="3.5" NUMPY_VERSION=1.11.2
|
||||
- UNCERTAINTIES="N" PYTHON="3.6" NUMPY_VERSION=1.11.2
|
||||
- UNCERTAINTIES="N" PYTHON="2.7" NUMPY_VERSION=0
|
||||
- UNCERTAINTIES="N" PYTHON="3.5" NUMPY_VERSION=0
|
||||
|
||||
|
@ -44,7 +45,7 @@ install:
|
|||
- if [ $UNCERTAINTIES == 'Y' ]; then pip install 'uncertainties==2.4.7.1'; fi
|
||||
- if [ $NUMPY_VERSION != '0' ]; then conda install --yes numpy==$NUMPY_VERSION; fi
|
||||
- if [ $PYTHON == '3.2' ]; then pip install coverage==3.7.1; else pip install coverage; fi
|
||||
- if [[ $TRAVIS_PYTHON_VERSION == '3.5' && $NUMPY_VERSION == 1.11.2 && $UNCERTAINTIES == "Y" ]]; then pip install serialize pyyaml; fi
|
||||
- if [[ $TRAVIS_PYTHON_VERSION == '3.5' && $NUMPY_VERSION == 1.11.2 && $UNCERTAINTIES == "Y" ]]; then pip install babel serialize pyyaml; fi
|
||||
- pip install coveralls
|
||||
|
||||
script:
|
||||
|
|
52
CHANGES
52
CHANGES
|
@ -4,8 +4,56 @@ Pint Changelog
|
|||
0.8 (unreleased)
|
||||
----------------
|
||||
|
||||
- Nothing changed yet.
|
||||
|
||||
- Refactored the Registry in multiple classes for better separation of concerns and clarity.
|
||||
- Implemented support for defining multiple units per `define` call (one definition per line).
|
||||
(Issue #462)
|
||||
- In pow and ipow, allow array exponents (with len > 1) when base is dimensionless.
|
||||
(Issue #483)
|
||||
- Wraps now gets the canonical name of the unit when passed as string.
|
||||
(Issue #468)
|
||||
- NumPy exp and log keeps the type
|
||||
(Issue #95)
|
||||
- Implemented a function decorator to ensure that a context is active (with_context)
|
||||
(Issue #465)
|
||||
- Add warning when a System contains an unknown Group.
|
||||
(Issue #472)
|
||||
- Add conda-forge installation snippet.
|
||||
(Issue #485, thanks stadelmanma)
|
||||
- Properly support floor division and modulo.
|
||||
(Issue #474, thanks tecki)
|
||||
- Measurement Correlated variable fix.
|
||||
(Issue #463, thanks tadhgmister)
|
||||
- Implement degree sign handling.
|
||||
(Issue #449, thanks iamthad)
|
||||
- Change `UndefinedUnitError` to inherit from `AttributeError`
|
||||
(Issue #480, thanks jhidding)
|
||||
- Simplified travis for faster testing.
|
||||
- Fixed order units in siunitx formatting.
|
||||
(Issue #441)
|
||||
- Changed Systems lister to return a list instead of frozenset.
|
||||
(Issue #425, thanks GloriaVictis)
|
||||
- Fixed issue with negative values in to_compact() method.
|
||||
(Issue #443, thanks nowox)
|
||||
- Improved defintions.
|
||||
(Issues #448, thanks gdonval)
|
||||
- Improved Parser to support capital "E" on scientific notation.
|
||||
(Issue #390, thanks javenoneal)
|
||||
- Make sure that prefixed units are defined on the registry when unplicking.
|
||||
(Issue #405)
|
||||
- Automatic unit names translation through babel.
|
||||
(Issue #338, thanks alexbodn)
|
||||
- Support pickling Unit objects.
|
||||
(Issue #349)
|
||||
- Add support for wavenumber/kayser in spectroscopy context.
|
||||
(Issue #321, thanks gerritholl)
|
||||
- Improved formatting.
|
||||
(thanks endolith and others)
|
||||
- Add support for inline comments in definitions file.
|
||||
(Issue #366)
|
||||
- Implement Unit.__deepcopy__.
|
||||
(Issue #357, thanks noahl)
|
||||
- Allow changing shape for Quantities with numpy arrays.
|
||||
(Issue #344, thanks tecki)
|
||||
|
||||
0.7.2 (2016-03-02)
|
||||
------------------
|
||||
|
|
|
@ -120,6 +120,27 @@ mass.
|
|||
<Quantity(19.0, 'mole')>
|
||||
|
||||
|
||||
Ensuring context when calling a function
|
||||
----------------------------------------
|
||||
|
||||
Pint provides a decorator to make sure that a function called is done within a given
|
||||
context. Just like before, you have to provide as argument the name (or alias) of the
|
||||
context and the parameters that you wish to set.
|
||||
|
||||
|
||||
.. doctest::
|
||||
|
||||
>>> wl = 530. * ureg.nm
|
||||
>>> @ureg.with_context('sp', n=1.33)
|
||||
... def f(wl):
|
||||
... return wl.to('Hz').magnitude
|
||||
>>> f(wl)
|
||||
398.496240602
|
||||
|
||||
|
||||
This decorator can be combined with **wraps** or **check** decorators described in `wrapping`_
|
||||
|
||||
|
||||
Defining contexts in a file
|
||||
---------------------------
|
||||
|
||||
|
|
|
@ -76,7 +76,8 @@ definitions does not involve changing the code.
|
|||
|
||||
**Advanced string formatting**: a quantity can be formatted into string using
|
||||
`PEP 3101`_ syntax. Extended conversion flags are given to provide symbolic,
|
||||
LaTeX and pretty formatting.
|
||||
LaTeX and pretty formatting. Unit name translation is available if Babel_ is
|
||||
installed.
|
||||
|
||||
**Free to choose the numerical type**: You can use any numerical type
|
||||
(`fraction`, `float`, `decimal`, `numpy.ndarray`, etc). NumPy_ is not required
|
||||
|
@ -149,3 +150,4 @@ One last thing
|
|||
.. _`uncertainties package`: https://pythonhosted.org/uncertainties/
|
||||
.. _`NumPy`: http://www.numpy.org/
|
||||
.. _`PEP 3101`: https://www.python.org/dev/peps/pep-3101/
|
||||
.. _`Babel`: http://babel.pocoo.org/
|
||||
|
|
|
@ -287,7 +287,7 @@ Pint also supports the LaTeX siunitx package:
|
|||
>>> print('The siunitx representation is {:Lx}'.format(accel))
|
||||
The siunitx representation is \SI[]{1.3}{\meter\per\second\squared}
|
||||
|
||||
Finally, you can specify a default format specification:
|
||||
Additionally, you can specify a default format specification:
|
||||
|
||||
.. doctest::
|
||||
|
||||
|
@ -298,6 +298,14 @@ Finally, you can specify a default format specification:
|
|||
'The acceleration is 1.3 meter/second²'
|
||||
|
||||
|
||||
Finally, if Babel_ is installed you can translate unit names to any language
|
||||
|
||||
.. doctest::
|
||||
|
||||
>>> accel.format_babel(locale='fr_FR')
|
||||
'1.3 mètre par seconde²'
|
||||
|
||||
|
||||
Using Pint in your projects
|
||||
---------------------------
|
||||
|
||||
|
@ -342,3 +350,4 @@ also define the registry as the application registry::
|
|||
|
||||
.. _eval: http://docs.python.org/3/library/functions.html#eval
|
||||
.. _`serious security problems`: http://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html
|
||||
.. _`Babel`: http://babel.pocoo.org/
|
||||
|
|
|
@ -182,8 +182,8 @@ To avoid the conversion of an argument or return value, use None
|
|||
>>> mypp3 = ureg.wraps((ureg.second, None), ureg.meter)(pendulum_period_error)
|
||||
|
||||
|
||||
Checking units
|
||||
==============
|
||||
Checking dimensionality
|
||||
=======================
|
||||
|
||||
When you want pint quantities to be used as inputs to your functions, pint provides a wrapper to ensure units are of
|
||||
correct type - or more precisely, they match the expected dimensionality of the physical quantity.
|
||||
|
|
|
@ -148,7 +148,6 @@ def formatter(items, as_ratio=True, single_denominator=False,
|
|||
other_lengths = []
|
||||
for _babel_length in [babel_length] + other_lengths:
|
||||
pat = unit_patterns.get(_key, {}).get(_babel_length, {}).get(plural)
|
||||
print(plural, _babel_length, pat)
|
||||
if pat is not None:
|
||||
key = pat.replace('{0}', '').strip()
|
||||
break
|
||||
|
|
Loading…
Reference in New Issue