UDST / urbanaccess

A tool for GTFS transit and OSM pedestrian network accessibility analysis by UrbanSim
https://udst.github.io/urbanaccess/index.html
GNU Affero General Public License v3.0
236 stars 56 forks source link

Updates for Python 3 #45

Closed smmaurer closed 5 years ago

smmaurer commented 5 years ago

This PR contains updates to provide Python 3 compatibility.

Most of the codebase is fine; we're already using cross-version syntax for print statements, errors, and integer division.

Changes

  1. Replaces urllib2.urlopen with the six.moves version, which automatically maps appropriately onto Python 2.7 and 3.x

  2. Replaces .dict[] lookup of urlopen().info() results with .get()

  3. Disables text encoding checks for Python 3 (general solution for detecting encodings will be in a future PR)

  4. Updates some syntax in the demo notebook

  5. Updates the setup script and Travis script for Python 3

Testing

I've been testing these changes locally using the demo notebook, in Python 2.7 and 3.6.

This is what the notebook output looks like: py2.7, py3.6.

The Travis script is updated to run the existing unit tests (minimal), demo notebook, and integration tests in Python 2.7, 3.5, and 3.6 (Travis doesn't support 3.7 smoothly yet).

UrbanAccess still requires Pandana v0.3; will add support for v0.4 in a separate PR.

Outstanding issues

The last three cells of the demo notebook, with Pandana plot commands, won't run on my machine either before or after this PR. They cause the kernel to die. (Mac OS 10.14, 32 GB RAM, Pandana 0.3, tried both Python 2.7 + Matplotlib 2 and Python 3.6 + Matplotlib 3.)

In Travis, it runs in Python 2.7 and often fails in Python 3. I am commenting out the code in these cells for the time being. (This is mostly resolved with Pandana 0.4; see PR #46.)

Versioning

This PR is labeled 0.2.dev1 in setup.py and the top-level __init__.py