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

hgrecco / pint / 1878
92%
master: 91%

Build:
Build:
LAST BUILD BRANCH: fix-nonmult-doc
DEFAULT BRANCH: master
Ran 19 Aug 2020 01:25AM UTC
Jobs 16
Files 18
Run time 8min
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
1878

push

travis-ci

web-flow
Merge #1150

1150: Add option to disable sorting of formatted unit components r=hgrecco a=lukelbd

- [ ] Closes # (insert issue number) (*n/a*)
- [x] Executed ``black -t py36 . && isort -rc . && flake8`` with no errors
- [ ] The change is fully covered by automated unit tests (*do I need to address this?*)
- [x] Documented in docs/ as appropriate
- [x] Added an entry to the CHANGES file

This is a very simple PR that adds a `sort` keyword argument to `pint.formatting.formatter`. The `sort` keyword can be set to `False` to optionally disable alphabetical sorting of the component units. This can be useful if your units are conventionally placed in a particular order, or conceptually easier to understand in a particular order.

Also, since preserving the dictionary insertion order is [an explicit python 3.6+ feature](https://docs.python.org/3/whatsnew/3.6.html#new-dict-implementation), the `unit: exponent` pairs in the `UnitsContainer` dictionaries can be reliably expected to preserve their original order, making this feature practically useful for formatting existing `Units` objects.

Here's a quick example with the conventional [specific heat capacity](https://en.wikipedia.org/wiki/Specific_heat_capacity) units:

```python

In  [1]: import pint
    ...: ureg = pint.UnitRegistry()
    ...: units = ureg.parse_units('J kg^-1 K^-1') 

In [2]: units.format_babel('C~', sort=True, as_ratio=False, product_fmt=' ')
Out[2]: 'J K**-1 kg**-1'

In [3]: units.format_babel('C~', sort=False, as_ratio=False, product_fmt=' ')
Out[3]: 'J kg**-1 K**-1'
```

Co-authored-by: Luke Davis <lukelbd@gmail.com>

3 of 3 new or added lines in 1 file covered. (100.0%)

3655 of 4076 relevant lines covered (89.67%)

11.8 hits per line

Jobs
ID Job ID Ran Files Coverage
1 1878.1 (PKGS="python=3.7 flake8 black isort") 19 Aug 2020 01:25AM UTC 0
0.0
Travis Job 1878.1
2 1878.2 (PKGS="python=3.7 ipython matplotlib nbsphinx numpy pandas jupyter_client ipykernel python-graphviz graphviz xarray sparse dask[complete] sphinx Pygments==2.3.1 docutils==0.14 alabaster commonmark==0.8.1 recommonmark==0.5.0") 19 Aug 2020 01:27AM UTC 0
0.0
Travis Job 1878.2
3 1878.3 (PKGS="python=3.6") 19 Aug 2020 01:25AM UTC 0
74.83
Travis Job 1878.3
4 1878.4 (PKGS="python=3.7") 19 Aug 2020 01:26AM UTC 0
74.83
Travis Job 1878.4
5 1878.5 (PKGS="python=3.8") 19 Aug 2020 01:25AM UTC 0
75.21
Travis Job 1878.5
6 1878.6 (PKGS="python=3.6 uncertainties=3.0") 19 Aug 2020 01:28AM UTC 0
88.15
Travis Job 1878.6
7 1878.7 (PKGS="python=3.7 uncertainties=3.0") 19 Aug 2020 01:28AM UTC 0
88.15
Travis Job 1878.7
8 1878.8 (PKGS="python=3.6 numpy=1.14 matplotlib") 19 Aug 2020 01:28AM UTC 0
84.4
Travis Job 1878.8
9 1878.9 (PKGS="python=3.7 numpy=1.14 matplotlib") 19 Aug 2020 01:29AM UTC 0
84.4
Travis Job 1878.9
10 1878.10 (PKGS="python=3.8 numpy=1.17 matplotlib") 19 Aug 2020 01:29AM UTC 0
87.29
Travis Job 1878.10
11 1878.11 (PKGS="python=3.6 numpy=1.14 uncertainties=3.0") 19 Aug 2020 01:31AM UTC 0
85.36
Travis Job 1878.11
12 1878.12 (PKGS="python=3.7 numpy=1.14 uncertainties=3.0") 19 Aug 2020 01:31AM UTC 0
85.36
Travis Job 1878.12
13 1878.13 (PKGS="python=3.6 numpy uncertainties") 19 Aug 2020 01:31AM UTC 0
88.15
Travis Job 1878.13
14 1878.14 (PKGS="python=3.7 numpy uncertainties") 19 Aug 2020 01:31AM UTC 0
88.15
Travis Job 1878.14
15 1878.15 (PKGS="python=3.8 numpy uncertainties") 19 Aug 2020 01:31AM UTC 0
88.32
Travis Job 1878.15
16 1878.16 (PKGS="python=3.8 numpy uncertainties sparse xarray netCDF4") 19 Aug 2020 01:33AM UTC 0
88.37
Travis Job 1878.16
Source Files on build 1878
  • Tree
  • List 18
  • Changed 2
  • Source Changed 1
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Travis Build #1878
  • adcb08a3 on github
  • Prev Build on staging (#1874)
  • Next Build on staging (#1881)
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

© 2025 Coveralls, Inc