Closed pksohn closed 7 years ago
On that long bullet about the index names: it might just make sense to convert the H5 file via a one-time process and leave the code alone.
Update: I reverted changes from this commit that converts bytes-type index names upon loading. Instead I upload an HDF5 file that has been converted - I think that's a more sustainable fix.
(This is a very similar writeup to the PR in developer. Pay attention to the first bullet under the code changes section). This PR includes several code changes to be compatible with Python 3, and changes the Travis build to work with Python 3.5 and 3.6. This is necessarily in parallel with changes to
developer
,pandana
,osmnet
, andurbansim
; running a simulation using Python 3 using this new codebase also requires Python 3 compatibility with several of the above. The Travis build currently grabs the py3-compatible branches of the above, so that will have to be updated over time.Code compatibility changes
pd.HDFStore()
and registering DataFrames as orca tables, the DataFrame index names (the column name of the column that got set to the index, i.e.df.index.name
) get read in as `numpy.bytestypes, then cast to the python 3 native
bytestype. In python 2, they get read in as strings. This surely has to do with the fact that python 3 now treats text and binary data separately, but I'm not sure why this affects the Dataframe index names specifically. Anyway, this makes it such that reading the DataFrames from HDF5 as usual breaks the model system when code tries to refer to the index name, like
building_id. So I added some handlers in
datasources.py` to encode the index names to string. This is a temporary fix that should have some more robust handling eventually.from __future__ import print_function
developer.py
module renamed todevelop.py
to avoid namespace conflict related to absolute imports.dict
:iteritems()
method replaced withitems()
(same behavior),dict.keys().sort()
changed tolist(dict.keys()).sort()
.from __future__ import division
in python 2. I manually checked all of the division operations against test data and they return the same arrays either way.Travis build changes
python3-support
branch (along with similar installation ofosmnet
).python3
branchpksohn/python3
fork/branchAgain, we'll just have to keep track of where the Travis builds are pulling code from. It should get much simpler as we merge changes into master branches.