Skip to content

Commit

Permalink
fixed python 2/3 incompatibility with itertools.izip_longest
Browse files Browse the repository at this point in the history
  • Loading branch information
claesenm committed May 17, 2015
1 parent e36c34a commit 8ce84b3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions optunity/solvers/Sobol.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@
import random
import array
import functools
import itertools
try:
# Python 2
from itertools import izip_longest
except ImportError:
# Python 3
from itertools import zip_longest as izip_longest

from ..functions import static_key_order
from .solver_registry import register_solver
Expand Down Expand Up @@ -184,7 +189,7 @@ def bitwise_xor(a, b):
abin = to_binary(a)[::-1]
bbin = to_binary(b)[::-1]
xor = lambda x, y: '0' if (x == y) else '1'
lst = [xor(x, y) for x, y in itertools.izip_longest(abin, bbin, fillvalue='0')]
lst = [xor(x, y) for x, y in izip_longest(abin, bbin, fillvalue='0')]
lst.reverse()
return int("".join(lst), 2)

Expand Down

0 comments on commit 8ce84b3

Please sign in to comment.