rmcantin / bayesopt

BayesOpt: A toolbox for bayesian optimization, experimental design and stochastic bandits.
GNU Affero General Public License v3.0
396 stars 92 forks source link

Python 3 support #10

Closed ericfrederich closed 7 years ago

ericfrederich commented 8 years ago

There isn't much Python code in this repo at all, just demos really. The interface is written in Cython which emits code that works with Python 2 or 3.

Because of this, it is trivial to support both 2 and 3 from the same code base.

Just some changes to print statements within the demos, and a simple bytes/strings conversion on the bopt parameters.

ericfrederich commented 8 years ago

Any word on this? I'd like to see it merged if possible. If there is an issue let me know, I'd be happy to accommodate.

rmcantin commented 8 years ago

Thanks Eric. I'll check this, as soon as possible.

Have you tested it in Python 2? I believe print(a,b) -that is, two or more things with a comma- is broken in Python 2.

ericfrederich commented 8 years ago

@rmcantin , This gets interpreted differently between Py2 and Py3 but does not break anything.

See... they both work fine but get interpreted a bit differently.

$ python3 -c "print(1, 'two')"
1 two
$ python2 -c "print(1, 'two')"
(1, 'two')

If you want the exact same behavior on 2 and 3 you can import print_function from __future__. Though I think this is overkill. The printout is just part of the installation process.

$ python2 -c "from __future__ import print_function; print(1, 'two')"
1 two
$ python3 -c "from __future__ import print_function; print(1, 'two')"
1 two