I am having trouble with the following function
def get_lexographically_next_bit_sequence(self, bits):
"""
Bit hack from here:
http://www-graphics.stanford.edu/~seander/bithacks.html#NextBitPermutation
Generator even does this in poker order rank
so no need to sort when done! Perfect.
"""
t = (bits | (bits - 1)) + 1
next = t | ((((t & -t) // (bits & -bits)) >> 1) - 1)
yield next
while True:
t = (next | (next - 1)) + 1
next = t | ((((t & -t) // (next & -next)) >> 1) - 1)
yield next
This function returns the error:
TypeError: unsupported operand type(s) for >>: 'float' and 'int'
Notes: This python library was only supported in 2.7 and I used 2to3 in order to use it. Other parts of the library work as desired, so I'm generally confident that 2to3 worked.
I am trying to run this in IPython 3.5 and I have heard that some errors like this can happen specifically within IPython, so I'm wondering if it's related to that.