osPlanning / omx

Open Matrix (OMX)
https://github.com/osPlanning/omx/wiki
Apache License 2.0
49 stars 18 forks source link

Python - default matrix TITLE attribute is some funny character that is causing problems #28

Closed bstabler closed 7 years ago

bstabler commented 7 years ago

The default matrix TITLE attribute is some funny character that is causing problems. In order to read our matrices into the OMX Viewer and VISUM, we had to override the TITLE after the matrix was created. We added the following bold line:

import openmatrix as omx outfile = omx.openFile(os.path.join(dir_data, 'transit_od_demandnew' + per + '.omx'), 'w') outfile['metro'] = od_matrix[i+1][0] outfile.createMapping('taz', taz_labels) outfile['metro'].attrs.TITLE = 'metro' outfile.close()

bstabler commented 7 years ago

The quick fix is to ensure TITLE really is just '' or something that won't cause problems

toliwaga commented 7 years ago

It looks like the problem opening files with an empty TITLE attribute is caused by a bug in pytables 3.0.0 that is fixed in 3.1.0

Given that this is caused by a bug, which is now fixed, it might make more sense just to be careful to always assign a TITLE attribute in the meantime. And then maybe somebody could rebuild OMX Viewer with an up-to-date version of pytables?

billyc commented 7 years ago

Thoughts?

bstabler commented 7 years ago

The TITLE attribute is optional so can we just not create it in the first place?

billyc commented 7 years ago

It's just the viewer that is expecting it, I think. We'd have to update the viewer to fix the problem, and I don't even remember where that code is! Hmm.

bstabler commented 7 years ago

The viewer doesn't require a title since I've used it for lots of other OMX files with matrices without TITLE

bstabler commented 7 years ago

The issue is that the pytables code is creating the bad TITLE - not the OMX code. So we'll try the update to pytables 3.1.0

billyc commented 7 years ago

Yep. Bumping pytables requirement to >= 3.1.0 to see if that fixes the problem.

billyc commented 7 years ago

uploaded openmatrix version 0.2.4 to pip.

pip install --upgrade openmatrix

should pull in the new pytables dependency. Happy testing!