Skip to content

Commit

Permalink
Version 0.0.3, added line member to Datapoint class
Browse files Browse the repository at this point in the history
  • Loading branch information
siznax committed Oct 18, 2019
1 parent cd7856d commit f145592
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion khnum/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'''

__author__ = '[email protected]'
__version__ = '0.0.2'
__version__ = '0.0.3'


from .datapoint import Datapoint as num
Expand Down
7 changes: 2 additions & 5 deletions khnum/datapoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ def __init__(self, num, units='d'):
'''
returns Datapoint instance
'''
self._num = num
self.cnum = khnum.cnum(num)
self.hnum = khnum.hnum(num, units)
self.type = str(type(num))
self.units = units
self.update(num, units)

def __str__(self):
return khnum.pretty(dict(self.__dict__))
Expand All @@ -33,4 +29,5 @@ def update(self, num, units='d'):
self._num = num
self.cnum = khnum.cnum(num)
self.hnum = khnum.hnum(num, units)
self.line = '{} ({})'.format(self.hnum, self.cnum)
self.units = units
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
packages=find_packages(),
tests_require=['pytest'],
url='https://github.com/siznax/khnum/',
version='0.0.2'
version='0.0.3'
)
4 changes: 4 additions & 0 deletions tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ def test_datapoint_update():

assert num.cnum == '987,654,321'
assert num.hnum == '987.7MB'

def test_datapoint_compact():
num = khnum.num(1234567890, 'b')
assert num.line == '1.2GB (1,234,567,890)'

0 comments on commit f145592

Please sign in to comment.