summaryrefslogtreecommitdiff
path: root/pint/util.py
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #1371 from keewis/custom-formatsJules Chéron2021-10-091-2/+2
|\ | | | | custom unit formats
| * explicitly pass the registry to `format_unit`Keewis2021-08-181-2/+2
| |
* | Merge branch 'master' into application_registryKeewis2021-08-201-4/+2
|\ \ | |/
| * Fix #1360 parsing units with same exponents but different signJules Chéron2021-08-051-4/+2
| |
* | remove _APP_DIRKeewis2021-08-081-2/+2
| |
* | save the actual registry in shared registry objectsKeewis2021-08-061-1/+1
|/
* Add pint typing moduleJules Chéron2021-08-011-15/+33
| | | | | | | | | | | | | | - Quantity as Generic class - Add overloaded signature for __new__ Quantity - Add typing module as private - Add py.typed for PEP561 supports - Add overloaded signature for __new__ Quantity - Quantity as Generic class - Add type hints throughout the project - Add py.typed in package data in setup.cfg - Add type hints for decorators - Add type hints for public API of registry.py - Add type hints for units.py
* Fix error on UnitsContainer equality checkRyan Rowe2020-09-251-1/+5
|
* Support pickle protocol 0/1Guido Imperiale2020-02-281-0/+15
| | | | | | | | | | | | | | More tests CHANGES Support pickle protocol 0/1 Polish
* Merge branch 'master' into _decimal_decimalHernan Grecco2020-02-211-4/+12
|\
| * Merge #999bors[bot]2020-02-021-4/+4
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 999: Preparing the codebase for a better Decimal support r=hgrecco a=hgrecco This is a series of three commits to prepare the codebase for a better Decimal support. These are mostly and internal clean up and should not affect any user. - [ ] ~~Closes # (insert issue number)~~ - [x] Executed ``black -t py36 . && isort -rc . && flake8`` with no errors - [ ] ~~The change is fully covered by automated unit tests~~ - [ ] ~~Documented in docs/ as appropriate~~ - [x] Added an entry to the CHANGES file Co-authored-by: Hernan <hernan.grecco@gmail.com>
| * | Add test for attribute _ and fix logic ;)Juan Nunez-Iglesias2020-01-151-4/+4
| | |
| * | Check for attributes containing only '_'Juan Nunez-Iglesias2020-01-151-2/+2
| | |
| * | Format strings according to blackJuan Nunez-Iglesias2020-01-151-1/+1
| | |
| * | Update docstring for getattr_maybe_raiseJuan Nunez-Iglesias2020-01-151-3/+7
| | |
| * | Don't raise error if key starts with _[digit]Juan Nunez-Iglesias2020-01-151-1/+5
| | |
* | | Add support for other numerical types at the registry levelHernan2020-01-221-28/+63
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* | Replace 1.0 and 0.0 (floats) by 1 and 0 (integers)Hernan2020-01-211-4/+4
|/ | | | | | | | | | 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.
* Fixes W293Hernan2019-12-271-21/+21
|
* Manual edits after pymentHernan2019-12-271-21/+0
|
* Run pyment -w --convert -o numpydoc .Hernan2019-12-271-39/+209
|
* Merge #920bors[bot]2019-12-201-2/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | 920: Fix autoreducedimension conversion r=hgrecco a=jules-ch * use iterable in function * Raise an error when trying to remove non existing key * Add test in test_issues.py * Update registry.py to remove unit when unit exists Closes #902 Co-authored-by: Jules Chéron <jules.cheron@gmail.com>
| * Fix autoreducedimension conversionJules Chéron2019-12-171-2/+2
| | | | | | | | | | | | | | | | | | * use iterable in function * Raise an error when trying to remove non existing key * Add test in test_issues.py * Update registry.py to remove unit when unit exists Closes #902
* | Parse NaN as a numberGuido Imperiale2019-12-191-10/+17
| |
* | Code qualityGuido Imperiale2019-12-191-9/+2
| |
* | Merge remote-tracking branch 'upstream/master' into context_define2Guido Imperiale2019-12-171-9/+10
|\ \ | |/
| * Remove redundant encoding information (utf8 is the default)Guido Imperiale2019-12-131-1/+0
| |
| * isortGuido Imperiale2019-12-131-4/+4
| |
| * flake8 fixesGuido Imperiale2019-12-131-4/+6
| |
* | # Conflicts:Guido Imperiale2019-12-161-11/+10
|/ | | | # pint/registry.py
* blackGuido Imperiale2019-12-131-76/+99
|
* Optimize setsGuido Imperiale2019-12-041-7/+6
|
* Remove Python 2 pickle idiosyncrasiesGuido Imperiale2019-12-031-14/+0
|
* Python 3 super()Guido Imperiale2019-12-031-5/+5
|
* More cleanupGuido Imperiale2019-12-031-13/+1
|
* Fix regressionGuido Imperiale2019-12-031-0/+8
|
* Remove 2.7 support from codebaseGuido Imperiale2019-12-031-5/+1
|
* Remove 2.7 support from codebaseGuido Imperiale2019-12-031-42/+36
|
* Global Quantity/Pint/Measurement to capture the application registry at init ↵Guido Imperiale2019-10-311-8/+9
| | | | time
* Merge remote-tracking branch 'upstream/master' into default_registryGuido Imperiale2019-10-311-0/+29
|\
| * Patch matplotlib.py for non-iterable argumentsJon Thielen2019-10-281-0/+29
| |
* | Sphinx fixesGuido Imperiale2019-09-131-1/+1
| |
* | Unit and Quantity in root moduleGuido Imperiale2019-09-131-1/+9
|/
* Minor comments tweakGuido Imperiale2019-09-111-3/+4
|
* Identical hashes do not guarantee equalityGuido Imperiale2019-09-111-27/+47
|
* Partially revert "Many speedups in UnitsContainer and ParserHelper"Guido Imperiale2019-09-111-39/+27
|
* Deep-copied UnitRegistries don't share state anymoreGuido Imperiale2019-08-301-1/+1
|
* Fix regression in Python 2.7Guido Imperiale2019-08-301-0/+14
|
* Successfully complete copy.deepcopy(UnitRegistry())Guido Imperiale2019-08-301-0/+10
|
* Many speedups in UnitsContainer and ParserHelperGuido Imperiale2019-08-301-31/+48
|