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

hgrecco / pint / 1653
92%
master: 91%

Build:
Build:
LAST BUILD BRANCH: fix-nonmult-doc
DEFAULT BRANCH: master
Ran 22 Feb 2020 03:19PM UTC
Jobs 16
Files 18
Run time 6min
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

pending completion
1653

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>

3548 of 3947 relevant lines covered (89.89%)

11.83 hits per line

Jobs
ID Job ID Ran Files Coverage
1 1653.1 (PKGS="python=3.7 flake8 black isort") 22 Feb 2020 03:19PM UTC 0
Travis Job 1653.1
2 1653.2 (PKGS="python=3.7 ipython matplotlib nbsphinx numpy sphinx Pygments==2.3.1 docutils==0.14 alabaster commonmark==0.8.1 recommonmark==0.5.0") 22 Feb 2020 03:20PM UTC 0
Travis Job 1653.2
3 1653.3 (PKGS="python=3.6") 22 Feb 2020 03:19PM UTC 0
75.35
Travis Job 1653.3
4 1653.4 (PKGS="python=3.7") 22 Feb 2020 03:19PM UTC 0
75.43
Travis Job 1653.4
5 1653.5 (PKGS="python=3.8") 22 Feb 2020 03:19PM UTC 0
75.81
Travis Job 1653.5
6 1653.6 (PKGS="python=3.6 uncertainties=3.0") 22 Feb 2020 03:21PM UTC 0
88.27
Travis Job 1653.6
7 1653.7 (PKGS="python=3.7 uncertainties=3.0") 22 Feb 2020 03:22PM UTC 0
88.27
Travis Job 1653.7
8 1653.8 (PKGS="python=3.6 numpy=1.14 matplotlib") 22 Feb 2020 03:22PM UTC 0
84.9
Travis Job 1653.8
9 1653.9 (PKGS="python=3.7 numpy=1.14 matplotlib") 22 Feb 2020 03:22PM UTC 0
84.9
Travis Job 1653.9
10 1653.10 (PKGS="python=3.8 numpy=1.17 matplotlib") 22 Feb 2020 03:23PM UTC 0
87.56
Travis Job 1653.10
11 1653.11 (PKGS="python=3.6 numpy=1.14 uncertainties=3.0") 22 Feb 2020 03:23PM UTC 0
85.94
Travis Job 1653.11
12 1653.12 (PKGS="python=3.7 numpy=1.14 uncertainties=3.0") 22 Feb 2020 03:24PM UTC 0
85.94
Travis Job 1653.12
13 1653.13 (PKGS="python=3.6 numpy uncertainties") 22 Feb 2020 03:24PM UTC 0
88.2
Travis Job 1653.13
14 1653.14 (PKGS="python=3.7 numpy uncertainties") 22 Feb 2020 03:24PM UTC 0
88.27
Travis Job 1653.14
15 1653.15 (PKGS="python=3.8 numpy uncertainties") 22 Feb 2020 03:25PM UTC 0
88.47
Travis Job 1653.15
16 1653.16 (PKGS="python xarray netCDF4") 22 Feb 2020 03:25PM UTC 0
86.89
Travis Job 1653.16
Source Files on build 1653
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #1653
  • 3aba60ec on github
  • Prev Build on staging (#1649)
  • Next Build on staging (#1660)
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