• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hgrecco / pint / 1653 / 6
92%
master: 91%

Build:
Build:
LAST BUILD BRANCH: fix-nonmult-doc
DEFAULT BRANCH: master
Ran 22 Feb 2020 03:21PM UTC
Files 18
Run time 1s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

22 Feb 2020 03:17PM UTC coverage: 88.273% (+0.003%) from 88.27%
PKGS="python=3.6 uncertainties=3.0"

push

travis-ci

web-flow
Merge #1000

1000: WIP: Add support for other numerical types at the registry level r=hgrecco a=hgrecco

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.
```python
 >>> from decimal import Decimal
 >>> ureg = UnitRegistry(non_int_type=Decimal)
```

- [x] Closes #968,  #967, #794, #452 
- [x] Executed ``black -t py36 . && isort -rc . && flake8`` with no errors
- [x] The change is fully covered by automated unit tests
- [x] Documented in docs/ as appropriate
- [x] Added an entry to the CHANGES file


Co-authored-by: Hernan <hernan.grecco@gmail.com>
Co-authored-by: Hernan Grecco <hernan.grecco@gmail.com>

3485 of 3948 relevant lines covered (88.27%)

0.88 hits per line

Source Files on job 1653.6 (PKGS="python=3.6 uncertainties=3.0")
  • Tree
  • List 0
  • Changed 6
  • Source Changed 6
  • Coverage Changed 6
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 1534
  • Travis Job 1653.6
  • 3aba60ec on github
  • Prev Job for PKGS="python=3.6 uncertainties=3.0" on staging (#1649.6)
  • Next Job for PKGS="python=3.6 uncertainties=3.0" on staging (#1660.6)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc