Browse Source

Fix integer divisions for Python 3

tags/nilmdb-2.0.0
Jim Paris 4 years ago
parent
commit
c83ee65cf7
2 changed files with 4 additions and 4 deletions
  1. +3
    -3
      nilmdb/client/numpyclient.py
  2. +1
    -1
      nilmdb/server/nilmdb.py

+ 3
- 3
nilmdb/client/numpyclient.py View File

@@ -18,11 +18,11 @@ def layout_to_dtype(layout):
ltype = layout.split('_')[0] ltype = layout.split('_')[0]
lcount = int(layout.split('_')[1]) lcount = int(layout.split('_')[1])
if ltype.startswith('int'): if ltype.startswith('int'):
atype = '<i' + str(int(ltype[3:]) / 8)
atype = '<i' + str(int(ltype[3:]) // 8)
elif ltype.startswith('uint'): elif ltype.startswith('uint'):
atype = '<u' + str(int(ltype[4:]) / 8)
atype = '<u' + str(int(ltype[4:]) // 8)
elif ltype.startswith('float'): elif ltype.startswith('float'):
atype = '<f' + str(int(ltype[5:]) / 8)
atype = '<f' + str(int(ltype[5:]) // 8)
else: else:
raise ValueError("bad layout") raise ValueError("bad layout")
return numpy.dtype([('timestamp', '<i8'), ('data', atype, lcount)]) return numpy.dtype([('timestamp', '<i8'), ('data', atype, lcount)])


+ 1
- 1
nilmdb/server/nilmdb.py View File

@@ -519,7 +519,7 @@ class NilmDB(object):
# Like bisect.bisect_left, but doesn't choke on large indices on # Like bisect.bisect_left, but doesn't choke on large indices on
# 32-bit systems, like bisect's fast C implementation does. # 32-bit systems, like bisect's fast C implementation does.
while lo < hi: while lo < hi:
mid = (lo + hi) / 2
mid = (lo + hi) // 2
if a[mid] < x: if a[mid] < x:
lo = mid + 1 lo = mid + 1
else: else:


Loading…
Cancel
Save