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

hgrecco / pint / 1413
91%

Build:
DEFAULT BRANCH: master
Ran 20 Dec 2019 01:20AM UTC
Jobs 13
Files 170
Run time 4min
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
1413

push

travis-ci

web-flow
Merge #938

938: Use contexts to redefine units r=hgrecco a=crusaderky

- [x] Closes #853 - Context.define for currency conversions
- [x] Closes #932 - Disable all throwaway contexts
- [x] Contexts that only implement transforms between dimensionalities (that is, all contexts until now) no longer require their own cache and therefore are enabled in microseconds even on the first time; contexts that implement redefinitions require a *much* smaller cache than before which is very quickly built on demand.
- [x] NaN is now parsed as a float

- [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


# Demo
```python
import pint

ureg = pint.UnitRegistry()
ureg.load_definitions("""
USD = [currency]
EUR = NaN USD
GBP = NaN USD

@context currencies_20191218
    EUR = 1.11 USD
    GBP = 1.18 EUR
@end

@context dungeons_and_dragons = dnd
    # Simplified conversion rates for the
    # non-English versions of the D&D manuals
    pound = 0.5 kg
    gallon = 4 l
    foot = 1.5/5 m
@end
""".splitlines())

>>> ureg.GBP.dimensionality
<UnitsContainer({'[currency]': 1.0})>
>>> ureg.Quantity("10 GBP")
10 GBP
>>> ureg.Quantity("10 GBP").to("USD")
nan USD
>>> ureg.Quantity("10 GBP").to("USD", "currencies_20191218")
13.098 USD
>>> ureg.Quantity("10 ft").to("m")
3.0479999999999996 meter
>>> ureg.Quantity("10 ft").to("m", "dnd")
3.0 meter
```


Co-authored-by: Guido Imperiale <crusaderky@gmail.com>

134 of 134 new or added lines in 4 files covered. (100.0%)

31235 of 36471 relevant lines covered (85.64%)

10.19 hits per line

Jobs
ID Job ID Ran Files Coverage
1 1413.1 (PKGS="python=3.7 flake8 black isort") 20 Dec 2019 01:20AM UTC 0
Travis Job 1413.1
2 1413.2 (PKGS="python=3.6") 20 Dec 2019 01:20AM UTC 0
76.4
Travis Job 1413.2
3 1413.3 (PKGS="python=3.7") 20 Dec 2019 01:20AM UTC 0
76.48
Travis Job 1413.3
4 1413.4 (PKGS="python=3.8") 20 Dec 2019 01:20AM UTC 0
76.77
Travis Job 1413.4
5 1413.5 (PKGS="python=3.6 uncertainties=3.0") 20 Dec 2019 01:21AM UTC 0
89.29
Travis Job 1413.5
6 1413.6 (PKGS="python=3.7 uncertainties=3.0") 20 Dec 2019 01:22AM UTC 0
89.37
Travis Job 1413.6
7 1413.7 (PKGS="python=3.6 numpy=1.14") 20 Dec 2019 01:22AM UTC 0
85.38
Travis Job 1413.7
8 1413.8 (PKGS="python=3.7 numpy=1.14") 20 Dec 2019 01:22AM UTC 0
85.38
Travis Job 1413.8
9 1413.9 (PKGS="python=3.8 numpy=1.17") 20 Dec 2019 01:22AM UTC 0
87.58
Travis Job 1413.9
11 1413.11 (PKGS="python=3.7 numpy=1.14 uncertainties=3.0") 20 Dec 2019 01:24AM UTC 0
87.31
Travis Job 1413.11
12 1413.12 (PKGS="python=3.6 numpy uncertainties") 20 Dec 2019 01:24AM UTC 0
89.37
Travis Job 1413.12
13 1413.13 (PKGS="python=3.7 numpy uncertainties") 20 Dec 2019 01:24AM UTC 0
89.37
Travis Job 1413.13
14 1413.14 (PKGS="python=3.8 numpy uncertainties") 20 Dec 2019 01:24AM UTC 0
89.46
Travis Job 1413.14
Source Files on build 1413
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #1413
  • 25dfa428 on github
  • Prev Build on master (#1406)
  • Next Build on master (#1415)
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