pyNLO / PyNLO

Python package for nonlinear optics
https://pynlo.readthedocs.io/en/latest/
GNU General Public License v3.0
101 stars 55 forks source link

Implement Python 3 compatibility #32

Closed DanHickstein closed 5 years ago

DanHickstein commented 8 years ago

This is a placeholder issue to remind us that we need to make PyNLO compatible with Python 3. It probably amounts to changing a lot of print statements, but there may also be other things that need to change.

pyNLO commented 6 years ago

A test branch which should be compatible in Python 2 & 3 is implemented (branch name: Python3.) The code passes the tests and I've checked that the DFG codes seem to work. This is expected, as most changes are to print statements.

DanHickstein commented 6 years ago

In another project, we have included the following lines on top of each file to ensure Py2+Py3 compatibility:

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

Many of these are mainly helpful if you have some developers (like me) who are still using Python 2. The print_function import throws an error if we try to use the old print syntax. The division imports makes sure there is no inconsistent integer division shenanigans.

Perhaps this would also be helpful here.

notsnhojelyk commented 6 years ago

If it helps, I did go through all the files and got it working on python-3. I removed all 'import extensions', changed the print statements and the lambda function definitions.

pynlo.zip

DanHickstein commented 6 years ago

Good work both of you!

Maybe @ycasg can make a PR from his Python3 branch (after catching it up to the master branch). And then @notsnhojelyk can compare with his branch and see if there are any more modification needed.

pyNLO commented 5 years ago

The main branch should now be Python 3 compatible. At the least, all of the example scripts work, the unit tests pass, and the DFG codes are working correctly. I'm closing this for now.