| Commit message (Collapse) | Author | Age | Files | Lines |
|\ |
|
| | |
|
|/ |
|
| |
|
|\ |
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Until this commit, `int` and `float` were special types in Pint
(just as they are in Python). Numbers were parsed from strings
as int/float from the definition files and from user provided
strings; and exponents of units were also stored as int/float.
This commit change this by adding a new argument (`non_int_type`)
to classes and methods. It indicates how numeric values will be parsed
and defaulted. Any numerical class can be used such as `float` (default),
Decimal, Fraction.
This argument will be found in the following places
1. UnitRegistry: used for parsing the definition files and any
value provided as a string.
2. UnitsContainer: used to compare equality with strings, multiply and
divide by strings (which is equivalent to parse the string)
3. All methods OUTSIDE the UnitRegistry/Quantity that can parse
strings have a `non_int_type` argument. (e.g. Definition.from_string)
Tests have been added for by duplicating most cases in `test_quantity.py`.
(Some tests have been deleted such as those dealing with numpy.)
The new file `test_non_int.py` run the tests for `Decimal`, `Fraction` and
`float` (which is redundant but is kept as a crosscheck for the implementation
of this testsuite)
BREAKING CHANGE: `use_decimal` is deprecated.
Use `non_int_type` keyword argument when instantiating the registry.
>>> from decimal import Decimal
>>> ureg = UnitRegistry(non_int_type=Decimal)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
In the original codebase, many accumulators, default values and so on were initialized
with floats (instead fo integers). The reason behind this decision was that in Python 2
the division (/) was by default an integer division if all values were ints. Therefore,
using a float ensured "the right result".
Now that the codebase is Python 3, we can safely use integers everywhere. This wil be
helpful when a different non integer type is desired.
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
1. UnitRegistry now has an optional keyword argument (`locale`) that can be
used to define the default value for `Quantity.format_babel` locale argument.
2. When Babel is not installed, `Quantity.format_babel` display a nicer and
more informative exception.
Closes #899, #904
|
| | |
|
| | |
|
| | |
|
| |\ |
|
| | |\ |
|
| | | | |
|
| | |/ |
|
| |/ |
|
| | |
|
| | |
|
| | |
|
| | |
|
|/ |
|
| |
|
|
|
|
|
|
|
|
| |
The commit also add a test to make sure that the definition file
included in Pint does not contain System with references to unknown
Groups
Close #472
|
|
|
| |
Return a list instead of a frozenset. Fixes #425
|
|\ |
|
| | |
|
| |
| |
| |
| | |
renamed the babel_units module to babel_names
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The module defines 5 registries with different capabilites:
- BaseRegistry: Basic unit definition and querying.
Conversion between multiplicative units.
- NonMultiplicativeRegistry: Conversion between non multiplicative (offset) units.
(e.g. Temperature)
* Inherits from BaseRegistry
- ContextRegisty: Conversion between units with different dimenstions according
to previously established relations (contexts).
(e.g. in the spectroscopy, conversion between frequency and energy is possible)
* Inherits from BaseRegistry
- SystemRegistry: Group unit and changing of base units.
(e.g. in MKS, meter, kilogram and second are base units.)
* Inherits from BaseRegistry
- UnitRegistry: Combine all previous capabilities, it is exposed by Pint.
There is performance penalty in some functions (< 10%) maybe due to method calls
but the code is cleaner a easier to understand.
|
|/ |
|
| |
|
| |
|
|
|
|
| |
Additionally used SourceIterator and improved error reporting
|
| |
|
| |
|
|
|
|
| |
See #215
|
|
The implementation is added in a separate, independent file
for prototyping. Functions are written independent of the
Registry.
Test for Groups are added.
|