bitmath-1.0.8-1 was published on 2014-08-14.

Major Updates

Bug Fixes

Changes

Added Functionality

Project

Tests

  • Test suite is now implemented using Python virtualenv’s for consistency across across platforms

  • Test suite now contains 150 unit tests. This is 110 more tests than the previous major release (1.0.4-1)

  • Test suite now runs on EPEL6 and EPEL7

  • Code coverage is stable around 95-100%

Examples

>>> import bitmath
>>> a_big_kib = bitmath.KiB(102400)
>>> print "Default:", a_big_kib, "| Best-prefix:", a_big_kib.best_prefix()
Default: 102400.0 KiB | Best-prefix: 100.0 MiB
>>> print (a_big_kib/3.0).format("{value:.3f}/{unit}")
34133.333/KiB
>>> print a_big_kib.bits, a_big_kib.system
838860800.0 NIST
>>> with bitmath.format(fmt_str="{value:.3f}/{unit}"):
... print bitmath.kB(12345.67890)
...
12345.679/kB
>>> with bitmath.format(plural=True):
... print bitmath.kB(12345.67890)
...
12345.6789 kBs
>>> print bitmath.KiB(1) == bitmath.KiB(1).to_Byte() == bitmath.Byte(1024).KiB
True
>>> print bitmath.getsize('.git/config')
672.0 Byte
>>> with bitmath.format(plural=True):
... for path, bm in bitmath.listdir('tests', relpath=True, filter='test_b*.py'):
... print "{path} is {value} {unit}".format(path=path, value=bm.value, unit=bm.unit)
...
tests/test_basic_math.py is 7349.0 Bytes
tests/test_bitwise_operations.py is 2701.0 Bytes
tests/test_best_prefix_BASE.py is 2155.0 Bytes
tests/test_best_prefix_NIST.py is 5562.0 Bytes
tests/test_best_prefix_SI.py is 5472.0 Bytes