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

hgrecco / pint / 798
92%
master: 91%

Build:
Build:
LAST BUILD BRANCH: fix-nonmult-doc
DEFAULT BRANCH: master
Ran 02 May 2018 03:57PM UTC
Jobs 12
Files 16
Run time 7min
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
798

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)

2834 of 3205 relevant lines covered (88.42%)

10.21 hits per line

Jobs
ID Job ID Ran Files Coverage
1 798.1 (UNCERTAINTIES="N" PYTHON="3.3" NUMPY_VERSION=1.9.2) 02 May 2018 03:57PM UTC 0
86.15
Travis Job 798.1
2 798.2 (UNCERTAINTIES="N" PYTHON="3.4" NUMPY_VERSION=1.11.2) 02 May 2018 03:57PM UTC 0
86.21
Travis Job 798.2
3 798.3 (UNCERTAINTIES="N" PYTHON="3.5" NUMPY_VERSION=1.11.2) 02 May 2018 03:57PM UTC 0
86.21
Travis Job 798.3
4 798.4 (UNCERTAINTIES="Y" PYTHON="3.5" NUMPY_VERSION=1.11.2) 02 May 2018 03:58PM UTC 0
88.14
Travis Job 798.4
5 798.5 (UNCERTAINTIES="N" PYTHON="3.6" NUMPY_VERSION=1.11.2) 02 May 2018 03:58PM UTC 0
86.21
Travis Job 798.5
6 798.6 (UNCERTAINTIES="N" PYTHON="2.7" NUMPY_VERSION=0) 02 May 2018 03:59PM UTC 0
77.66
Travis Job 798.6
7 798.7 (UNCERTAINTIES="N" PYTHON="3.5" NUMPY_VERSION=0) 02 May 2018 04:00PM UTC 0
77.66
Travis Job 798.7
8 798.8 (UNCERTAINTIES="N" PYTHON="2.7" NUMPY_VERSION=1.14) 02 May 2018 04:01PM UTC 0
86.21
Travis Job 798.8
9 798.9 (UNCERTAINTIES="N" PYTHON="3.4" NUMPY_VERSION=1.14) 02 May 2018 04:03PM UTC 0
86.05
Travis Job 798.9
10 798.10 (UNCERTAINTIES="N" PYTHON="3.5" NUMPY_VERSION=1.14) 02 May 2018 04:02PM UTC 0
86.15
Travis Job 798.10
11 798.11 (UNCERTAINTIES="Y" PYTHON="3.5" NUMPY_VERSION=1.14) 02 May 2018 04:04PM UTC 0
88.08
Travis Job 798.11
12 798.12 (UNCERTAINTIES="N" PYTHON="3.6" NUMPY_VERSION=1.14) 02 May 2018 04:04PM UTC 0
86.15
Travis Job 798.12
Source Files on build 798
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #798
  • ab5cd651 on github
  • Prev Build on staging (#793)
  • Next Build on staging (#800)
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