AIworx-Labs / chocolate

A fully decentralized hyperparameter optimization framework
http://chocolate.readthedocs.io
BSD 3-Clause "New" or "Revised" License
121 stars 41 forks source link

added __ne__ methods for python 2 compatibility #24

Closed jackd closed 5 years ago

jackd commented 5 years ago

python2 does not automatically use __eq__ for __ne__ implementation. Everything else in here seems to work with python2, but by not implementing __ne__ , this check raises an error whenever restarting from an existing database in python 2.

Bug demonstration:

import chocolate as choco
space0 = choco.space.Space({'a': choco.uniform(0, 1)})
space1 = choco.space.Space({'a': choco.uniform(0, 1)})
print(space0 == space1)                          # True, as expected
print(space0 != space1)                           # True <-------------- very unexpected

print(space0.spaces == space1.spaces) # True, as expected
print(space0.spaces != space1.spaces) # False, as expected

Sorry about the whitespace changes - only just noticed them... happy to roll back and re-issue if that's a problem...

leconteur commented 5 years ago

Looks good to me.