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

hgrecco / pint / 1413 / 11
91%
master: 91%

Build:
DEFAULT BRANCH: master
Ran 20 Dec 2019 01:24AM UTC
Files 17
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

20 Dec 2019 01:12AM UTC coverage: 87.308% (+0.2%) from 87.136%
PKGS="python=3.7 numpy=1.14 uncertainties=3.0"

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>

3178 of 3640 relevant lines covered (87.31%)

0.87 hits per line

Source Files on job 1413.11 (PKGS="python=3.7 numpy=1.14 uncertainties=3.0")
  • Tree
  • List 0
  • Changed 4
  • Source Changed 4
  • Coverage Changed 4
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 1305
  • Travis Job 1413.11
  • 25dfa428 on github
  • Prev Job for PKGS="python=3.7 numpy=1.14 uncertainties=3.0" on master (#1406.11)
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