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

hgrecco / pint / 799
91%

Build:
DEFAULT BRANCH: master
Ran 02 May 2018 04:08PM UTC
Jobs 12
Files 16
Run time 9min
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
799

push

travis-ci

bors[bot]
Merge #638

638: Add if to handle np.array with ndim == 0 on latex repr. r=hgrecco a=raphaeltimbo

Closes #587.
This adds a check for the array dimension. If it is 0, a reshaped array is
used (with dim = 1). 
The purpose of this PR is that ```Q_([1], 'bar')```, ```Q_(np.array([1]), 'bar')``` and ```Q_(np.array(1), 'bar')``` will have the same latex output in the jupyter notebook.
Currently, we have the following behavior on the jupyter notebook:

```python
import pint
import numpy as np

ureg = pint.UnitRegistry()
Q_ = ureg.Quantity

Q_([1], 'bar')
output : (1)bar

Q_(np.array([1]), 'bar')
output : (1)bar

Q_(np.array(1), 'bar')
output : 
---------------------------------------------------------
TypeError               Traceback (most recent call last)
~/anaconda3/envs/prf/lib/python3.6/site-packages/IPython/core/formatters.py in __call__(self, obj)
    343             method = get_real_method(obj, self.print_method)
    344             if method is not None:
--> 345                 return method()
    346             return None
    347         else:

~/pint/pint/util.py in _repr_html_(self)
    634             return "{:~H}".format(self)
    635         else:
--> 636             return "{:H}".format(self)
    637 
    638     def _repr_latex_(self):

~/pint/pint/quantity.py in __format__(self, spec)
    187                 # this is required to have the magnitude and unit in the same line
    188                 allf = r'\[{} {}\]'
--> 189                 parts = ndarray_to_latex_parts(obj.magnitude, mspec)
    190 
    191                 if len(parts) > 1:

~/pint/pint/formatting.py in ndarray_to_latex_parts(ndarr, fmtfun, dim)
    310                 ret += [header % elno + ' = ' + matrix_to_latex(el, fmtfun)]
    311         else:
--> 312             for elno, el in enumerate(ndarr):
    313                 ret += ndarray_to_latex_parts(el, fmtfun, dim + (elno, ))
    314 

TypeError: iteration ... (continued)

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

2834 of 3205 relevant lines covered (88.42%)

10.21 hits per line

New Missed Lines in Diff

Lines Coverage ∆ File
3
100.0
pint/formatting.py
Jobs
ID Job ID Ran Files Coverage
1 799.1 (UNCERTAINTIES="N" PYTHON="3.3" NUMPY_VERSION=1.9.2) 02 May 2018 04:08PM UTC 0
86.05
Travis Job 799.1
2 799.2 (UNCERTAINTIES="N" PYTHON="3.4" NUMPY_VERSION=1.11.2) 02 May 2018 04:08PM UTC 0
86.21
Travis Job 799.2
3 799.3 (UNCERTAINTIES="N" PYTHON="3.5" NUMPY_VERSION=1.11.2) 02 May 2018 04:10PM UTC 0
86.12
Travis Job 799.3
4 799.4 (UNCERTAINTIES="Y" PYTHON="3.5" NUMPY_VERSION=1.11.2) 02 May 2018 04:08PM UTC 0
88.14
Travis Job 799.4
5 799.5 (UNCERTAINTIES="N" PYTHON="3.6" NUMPY_VERSION=1.11.2) 02 May 2018 04:08PM UTC 0
86.21
Travis Job 799.5
6 799.6 (UNCERTAINTIES="N" PYTHON="2.7" NUMPY_VERSION=0) 02 May 2018 04:10PM UTC 0
77.66
Travis Job 799.6
7 799.7 (UNCERTAINTIES="N" PYTHON="3.5" NUMPY_VERSION=0) 02 May 2018 04:11PM UTC 0
77.66
Travis Job 799.7
8 799.8 (UNCERTAINTIES="N" PYTHON="2.7" NUMPY_VERSION=1.14) 02 May 2018 04:12PM UTC 0
86.21
Travis Job 799.8
9 799.9 (UNCERTAINTIES="N" PYTHON="3.4" NUMPY_VERSION=1.14) 02 May 2018 04:14PM UTC 0
86.15
Travis Job 799.9
10 799.10 (UNCERTAINTIES="N" PYTHON="3.5" NUMPY_VERSION=1.14) 02 May 2018 04:14PM UTC 0
86.15
Travis Job 799.10
11 799.11 (UNCERTAINTIES="Y" PYTHON="3.5" NUMPY_VERSION=1.14) 02 May 2018 04:17PM UTC 0
88.08
Travis Job 799.11
12 799.12 (UNCERTAINTIES="N" PYTHON="3.6" NUMPY_VERSION=1.14) 02 May 2018 04:16PM UTC 0
86.15
Travis Job 799.12
Source Files on build 799
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #799
  • ab5cd651 on github
  • Prev Build on master (#794)
  • Next Build on master (#801)
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