Make it work with Python 2 again

This commit is contained in:
Chris Kerr
2014-11-07 16:30:27 +00:00
parent 7da8b8b5e6
commit 6973fc4e5c

View File

@@ -16,8 +16,10 @@ import numpy as np
if sys.version_info.major <= 2: if sys.version_info.major <= 2:
str3 = str str3 = str
from string import maketrans
else: else:
str3 = lambda b: str(b, encoding='ascii') str3 = lambda b: str(b, encoding='ascii')
maketrans = bytes.maketrans
def fieldname_to_dtype(fieldname): def fieldname_to_dtype(fieldname):
@@ -50,7 +52,7 @@ def fieldname_to_dtype(fieldname):
def comma_converter(float_string): def comma_converter(float_string):
"""Convert numbers to floats whether the decimal point is '.' or ','""" """Convert numbers to floats whether the decimal point is '.' or ','"""
trans_table = bytes.maketrans(b',', b'.') trans_table = maketrans(b',', b'.')
return float(float_string.translate(trans_table)) return float(float_string.translate(trans_table))