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

hgrecco / pint / 799 / 4
91%
master: 91%

Build:
DEFAULT BRANCH: master
Ran 02 May 2018 04:08PM UTC
Files 16
Run time 32s
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

02 May 2018 03:54PM UTC coverage: 88.144% (-0.08%) from 88.226%
UNCERTAINTIES="Y" PYTHON="3.5" NUMPY_VERSION=1.11.2

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)

2825 of 3205 relevant lines covered (88.14%)

0.88 hits per line

Source Files on job 799.4 (UNCERTAINTIES="Y" PYTHON="3.5" NUMPY_VERSION=1.11.2)
  • Tree
  • List 0
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 777
  • Travis Job 799.4
  • ab5cd651 on github
  • Prev Job for UNCERTAINTIES="Y" PYTHON="3.5" NUMPY_VERSION=1.11.2 on master (#794.4)
  • Next Job for UNCERTAINTIES="Y" PYTHON="3.5" NUMPY_VERSION=1.11.2 on master (#801.4)
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