Skip to content

Commit

Permalink
Adjust type comparison for Windows
Browse files Browse the repository at this point in the history
 - handle the fact the np.dype('i4') == int (Python native int) on
   Windows machines. This messes up the logic in the format_print
   function
  • Loading branch information
talumbau committed Dec 20, 2016
1 parent 28649b4 commit dced001
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion taxcalc/dropq/dropq_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@

def format_print(x, _type, num_decimals):
float_types = [float, np.dtype('f8')]
int_types = [int, np.dtype('i8')]
frmat_str = "0:.{num}f".format(num=num_decimals)
frmat_str = "{" + frmat_str + "}"
try:
if _type in float_types or _type is None:
return frmat_str.format(x)
elif _type == int:
elif _type in int_types:
return str(int(x))
elif _type == str:
return str(x)
Expand Down
2 changes: 1 addition & 1 deletion taxcalc/tests/test_dropq.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def test_chooser():


def test_format_print_not_implemented():
x = np.array([1], dtype='i4')
x = np.array([1], dtype='i2')
with pytest.raises(NotImplementedError):
format_print(x[0], x.dtype, 2)

Expand Down

0 comments on commit dced001

Please sign in to comment.