Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating print statements for Python 3 compatibility #101

Merged
merged 17 commits into from
Nov 19, 2019

Conversation

smmaurer
Copy link

This PR updates print statements throughout bayarea_urbansim to support Python 2.7 and 3.x concurrently. This is the first part of a larger set of cross-compatibility updates, described in https://github.com/urbansim/mtc-planning/issues/4.

Thanks to @alephcero for all the work on this!

Testing

  • Using Python 2.7, the default scenario runs to 2050 without errors
  • Print behavior in the logs appears unchanged

No reason to expect any model logic to change, but we set a random seed and checked runXX_taz_summaries_2015.csv just in case -- identical output.

Notes about merging

This PR includes the fixes to support NumPy 1.16, from PR #99, because we'd already merged them into the master branch of our fork.

So it will probably go smoother if you merge #99 before merging this one. If you decide not to merge #99, we can revert those commits from this PR -- it's the first 5, from June 8 and June 17, and it's easiest to revert things in reverse order!

@theocharides
Copy link

Hi @smmaurer, your separate PRs and testing for the Python3 updates are great.

Is this import line so the updates will work in Python2 as well? If so, does baus.py also need it?
https://github.com/BayAreaMetro/bayarea_urbansim/pull/101/files#diff-3823f3bae2739d8cd364bbfd1b29e21aR1

@smmaurer
Copy link
Author

Hi @theocharides -

Yes, the import line is the official way to support print() in Python 2. So we should add it to baus.py as well.

Incidentally, I think Python 2.7 supports print statements with parentheses even without the special import, but including it makes things more reliable. The model log formatting didn't look quite right until we included it.

@smmaurer smmaurer mentioned this pull request Oct 16, 2019
@theocharides
Copy link

Identical TAZ 2050 files using Windows, with and without PR. Tested Python 2 (numpy 1.10.0), but am unable to test Python 3 at this juncture since the rest of the Python 3 updates aren't in place.

@theocharides theocharides merged commit edca3f3 into BayAreaMetro:master Nov 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants