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

hgrecco / pint / 658
92%
master: 91%

Build:
Build:
LAST BUILD BRANCH: fix-nonmult-doc
DEFAULT BRANCH: master
Ran 31 Mar 2017 04:03AM UTC
Jobs 8
Files 15
Run time 3min
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
658

push

travis-ci

bors[bot]
Merge #474

474: Actually support floor division and modulo r=hgrecco
Floor division is currently broken in pint. It is implemented like the normal division, just calling the floor division operator on the magnitude.

This is wrong. Floor division with units serves an important use case: imagine the question "I have a 1 m long log, how may pieces of 1 in can I make from that?". This question has a clear answer (it's 39), but pint gives the weird answer "1 meter / inch", which is just wrong.

Python gives a clear definition of what is expected for the divmod function, which calculates floor division and the modulo: "For floating point numbers the result is (q, a % b), where q is usually math.floor(a / b) but may be 1 less than that. In any case q * b + a % b is very close to a, if a % b is non-zero it has the same sign as b, and 0 <= abs(a % b) < abs(b)".

This statement also works well in the united case. The implications are: a // b must be unitless, because the floor of a united value does not make sense. a % b must have the same unit (or at least dimensionality) as a (and b), as otherwise the above sum looses sense.

This pull request implements and tests all of the above.

2707 of 3032 relevant lines covered (89.28%)

6.79 hits per line

Jobs
ID Job ID Ran Files Coverage
1 658.1 (UNCERTAINTIES="N" PYTHON="2.6" NUMPY_VERSION=1.9.2) 31 Mar 2017 04:03AM UTC 0
86.94
Travis Job 658.1
2 658.2 (UNCERTAINTIES="N" PYTHON="2.7" NUMPY_VERSION=1.11.2) 31 Mar 2017 04:03AM UTC 0
86.97
Travis Job 658.2
3 658.3 (UNCERTAINTIES="N" PYTHON="3.3" NUMPY_VERSION=1.9.2) 31 Mar 2017 04:03AM UTC 0
86.84
Travis Job 658.3
4 658.4 (UNCERTAINTIES="N" PYTHON="3.4" NUMPY_VERSION=1.11.2) 31 Mar 2017 04:03AM UTC 0
86.91
Travis Job 658.4
5 658.5 (UNCERTAINTIES="N" PYTHON="3.5" NUMPY_VERSION=1.11.2) 31 Mar 2017 04:03AM UTC 0
86.91
Travis Job 658.5
6 658.6 (UNCERTAINTIES="Y" PYTHON="3.5" NUMPY_VERSION=1.11.2) 31 Mar 2017 04:05AM UTC 0
88.95
Travis Job 658.6
7 658.7 (UNCERTAINTIES="N" PYTHON="2.7" NUMPY_VERSION=0) 31 Mar 2017 04:06AM UTC 0
77.9
Travis Job 658.7
8 658.8 (UNCERTAINTIES="N" PYTHON="3.5" NUMPY_VERSION=0) 31 Mar 2017 04:06AM UTC 0
77.9
Travis Job 658.8
Source Files on build 658
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #658
  • db336319 on github
  • Prev Build on staging (#657)
  • Next Build on staging (#659)
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