{"action":"created","issue":{"url":"https://api.github.com/repos/GalSim-developers/GalSim/issues/761","repository_url":"https://api.github.com/repos/GalSim-developers/GalSim","labels_url":"https://api.github.com/repos/GalSim-developers/GalSim/issues/761/labels{/name}","comments_url":"https://api.github.com/repos/GalSim-developers/GalSim/issues/761/comments","events_url":"https://api.github.com/repos/GalSim-developers/GalSim/issues/761/events","html_url":"https://github.com/GalSim-developers/GalSim/pull/761","id":160871288,"number":761,"title":"#534 Support Python 3","user":{"login":"rmjarvis","id":623887,"avatar_url":"https://avatars.githubusercontent.com/u/623887?v=3","gravatar_id":"","url":"https://api.github.com/users/rmjarvis","html_url":"https://github.com/rmjarvis","followers_url":"https://api.github.com/users/rmjarvis/followers","following_url":"https://api.github.com/users/rmjarvis/following{/other_user}","gists_url":"https://api.github.com/users/rmjarvis/gists{/gist_id}","starred_url":"https://api.github.com/users/rmjarvis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmjarvis/subscriptions","organizations_url":"https://api.github.com/users/rmjarvis/orgs","repos_url":"https://api.github.com/users/rmjarvis/repos","events_url":"https://api.github.com/users/rmjarvis/events{/privacy}","received_events_url":"https://api.github.com/users/rmjarvis/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":30,"created_at":"2016-06-17T11:49:42Z","updated_at":"2016-06-25T00:52:22Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/GalSim-developers/GalSim/pulls/761","html_url":"https://github.com/GalSim-developers/GalSim/pull/761","diff_url":"https://github.com/GalSim-developers/GalSim/pull/761.diff","patch_url":"https://github.com/GalSim-developers/GalSim/pull/761.patch"},"body":"This PR converts the GalSim code to work with Python 3.  So if you have access to a Python 3 installation, please test that everything works for you there.  And if not, at least check that I didn't break your Python 2 installation with anything here.\r\n\r\nI added a new dependency, called future, to help enable this.  While I didn't technically need it (I could have rolled my own versions of the features I use from there), it's a pretty easy dependency, so hopefully it won't be a significant hardship for anyone.  But it means you'll probably need to run `pip install future` before installing GalSim on this branch.\r\n\r\nFor reference, I used this handy [cheat sheet](http://python-future.org/compatible_idioms.html) extensively for writing the Python 2-3 compatible code.  This [guide](http://python3porting.com/noconv.html#noconv-chapter) also had some useful advice, but it was not nearly as comprehensive.\r\n\r\nFinally, Python 3 added a ResourceWarning that lets you know when you've forgotten to close files.  I'm not sure if this only happens when running in nosetests or what (I didn't get them when I ran individual test files), but it helped me track down a lot of places where we were doing that.  The biggest culprit was `python.getdata`, which seems to not (or not always) close the input file.  So I switched all of those to `with python.open(..)` blocks, which fixed those errors.  There were a number of others that were our fault.  \r\n\r\nThe trickiest one was that `galsim.fits.read` could raise an exception before getting to the place where it closes the files.  It turns out, this is precisely what the python `try... finally` construct is for, so I used that, which makes for nicer code there."},"comment":{"url":"https://api.github.com/repos/GalSim-developers/GalSim/issues/comments/228497332","html_url":"https://github.com/GalSim-developers/GalSim/pull/761#issuecomment-228497332","issue_url":"https://api.github.com/repos/GalSim-developers/GalSim/issues/761","id":228497332,"user":{"login":"jmeyers314","id":3650485,"avatar_url":"https://avatars.githubusercontent.com/u/3650485?v=3","gravatar_id":"","url":"https://api.github.com/users/jmeyers314","html_url":"https://github.com/jmeyers314","followers_url":"https://api.github.com/users/jmeyers314/followers","following_url":"https://api.github.com/users/jmeyers314/following{/other_user}","gists_url":"https://api.github.com/users/jmeyers314/gists{/gist_id}","starred_url":"https://api.github.com/users/jmeyers314/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmeyers314/subscriptions","organizations_url":"https://api.github.com/users/jmeyers314/orgs","repos_url":"https://api.github.com/users/jmeyers314/repos","events_url":"https://api.github.com/users/jmeyers314/events{/privacy}","received_events_url":"https://api.github.com/users/jmeyers314/received_events","type":"User","site_admin":false},"created_at":"2016-06-25T00:52:22Z","updated_at":"2016-06-25T00:52:22Z","body":"I just noticed that demo13.py is failing for me under python2.7 with the message:\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"demo13.py\", line 473, in <module>\r\n    main(sys.argv)\r\n  File \"demo13.py\", line 462, in main\r\n    final_image.write(out_filename)\r\n  File \"/Users/josh/src/GalSim/galsim/fits.py\", line 550, in write\r\n    image.wcs.writeToFitsHeader(hdu.header, image.bounds)\r\n  File \"/Users/josh/src/GalSim/galsim/wcs.py\", line 547, in writeToFitsHeader\r\n    for key in self.header:\r\nTypeError: iter() returned non-iterator of type 'instancemethod'\r\n```\r\n\r\nwhich appears to be related to [this line](https://github.com/GalSim-developers/GalSim/blob/%23534/galsim/wcs.py#L547) in wcs.py.\r\n\r\nI also noticed that fits.FitsHeader has two definitions of `__len__`.\r\n\r\nMay be this is due to most recent version of astropy (v1.2)?\r\n\r\nI'll check these on python3.5 too."}}
{"actor":{"display_login":"jmeyers314"}}