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

hgrecco / pint / 377 / 5
91%
master: 91%

Build:
DEFAULT BRANCH: master
Ran 05 Feb 2015 10:09PM UTC
Files 7
Run time 2s
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

05 Feb 2015 10:07PM UTC coverage: 79.553% (+0.02%) from 79.533%
UNCERTAINTIES="Y" NUMPY_VERSION=0

Pull #231

travis-ci

jpgrayson
Introduce 'u' to format only a Quantity's units

It is currently not possible to correctly format units (UnitsContainer
objects) using the '~' format spec.

    >>> format(q, '~')
    '17.0 km / s ** 2'
    >>> format(q.units, '~')
    'kilometer / second ** 2'

Notice how the units are different when formatted on their own.

In order for units to be properly formatted with '~', the UnitsRegistry
must be available so that the long names in the units container can be
mapped to their short, symbolic names. I.e. 'kilo' -> 'k' and 'meter' ->
'm'. A key problem is that UnitsContainer objects do not have access to
the UnitRegistry. When quantities are formatted, we cheat (a little) and
use the quantity's UnitRegistry (_REGISTRY) to perform the _get_symbol()
mapping in the case of '~'.

So we introduce 'u' as a formatting spec for Quantity that causes only
the unit, and not the magnitude, to be returned from format().

    >>> format(q, '~u')
    'km / s ** 2'
    >>> format(q, '~Pu')
    'km/s²'
Pull Request #231: Introduce 'u' to format only a Quantity's units

1603 of 2015 relevant lines covered (79.55%)

0.8 hits per line

Source Files on job 377.5 (UNCERTAINTIES="Y" NUMPY_VERSION=0)
  • Tree
  • List 0
  • Changed 2
  • Source Changed 1
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 377
  • Travis Job 377.5
  • 8a0562dc on github
  • Prev Job for UNCERTAINTIES="Y" NUMPY_VERSION=0 on master (#376.33)
  • Next Job for UNCERTAINTIES="Y" NUMPY_VERSION=0 on master (#380.5)
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