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

hgrecco / pint / 783 / 2
91%
master: 91%

Build:
DEFAULT BRANCH: master
Ran 13 Apr 2018 11:15PM UTC
Files 16
Run time 0s
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

13 Apr 2018 10:59PM UTC coverage: 86.196% (-0.01%) from 86.207%
UNCERTAINTIES="N" PYTHON="3.4" NUMPY_VERSION=1.11.2

push

travis-ci

bors[bot]
Merge #630

630: Fix unit tests errors with numpy >=1.13 (Fix 577) r=cpascual a=cpascual

This PR fixes the 4 test errors/failiures reported in #577 and adds new travis builds with numpy 1.14

3 of the 4 problems are relatively trivial to solve.

The remaining one (`test_isreal`) is not so trivial because it  involves allowing to compare a *non-dimensionless* quantity against zero. The reason is that `numpy.isreal(x)` essentially does `x.imag !=0` if the `imag` method is implemented in x... and since Quantity reimplements .imag to return units (see #171), the check always returns False if x is a non-dimensionless quantity.

As mentioned, this can be solved by allowing comparisons against zero. Actually, this has already been requested in #194, but it was not implemented.

In this PR, I implemented the comparison-to-zero feature and provide several new unit tests for it. AFAIK this implementation takes into account the concerns expressed by @hgrecco in #194. But if the feature is not wanted, we can just revert the last 3 commits of this PR and then `test_isreal` will left with an expected failure flag.

The rules that I implemented for the comparison-with-zero are:
```    
    a) comparing against (non-quantity) zero is allowed for any quantity
    b) comparing against zero-magnitude quantities of incompatible
    dimensionality raises a Dimensionality error, except for the case
    of equality, for which it always returns False
    
    Notes:
    1.- Numpy arrays of zeros are also supported and the comparison rules
    apply elementwise
    2.- In the case of non-multiplicative units, the rules above
    apply after converting to base units if the autoconvert offset flag
    is set. Otherwise they raise an OffsetUnitCalculusError.
```

Fixes #577


Co-authored-by: Carlos Pascual <cpascual@cells.es>

2760 of 3202 relevant lines covered (86.2%)

0.86 hits per line

Source Files on job 783.2 (UNCERTAINTIES="N" PYTHON="3.4" NUMPY_VERSION=1.11.2)
  • Tree
  • List 0
  • Changed 2
  • Source Changed 1
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 762
  • Travis Job 783.2
  • fc2c503b on github
  • Prev Job for UNCERTAINTIES="N" PYTHON="3.4" NUMPY_VERSION=1.11.2 on master (#775.3)
  • Next Job for UNCERTAINTIES="N" PYTHON="3.4" NUMPY_VERSION=1.11.2 on master (#787.2)
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