-
Notifications
You must be signed in to change notification settings - Fork 4
2/3 compatibility #22
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
base: master
Are you sure you want to change the base?
Conversation
cdlparser.py -- initial 2/3 compatibility steps cdlparser.py -- 2/3 compatibility fix octal strings to use 0o cdlparser.py -- Fix variable name cdlparser.py -- 2/3 integer division cdlparser.py -- 2/3 string_escape compatibility. CDL files must be utf-8 compatible. test_constants.py -- 2/3 compat -- keys() is an iterator in PY3 and cannot be indexed. test_charvars.py -- 2/3 compat. netcdf NC_CHAR are bytes, not strings cdlparser.py -- 2/3 basestring compatibility
|
Whoops, I didn't see the other pull request. I didn't try to compare the cdlparser.py code from that PR, but there are some similar changes to the tests, though actually I think that PR has some better improvements to test_constants.py. But I did try to keep this PR narrowly focused to 2/3 compatibility and no pep8'ing! |
|
Edit: Nevermind, I do understand the function (you can have e.g. |
cdlparser.py -- remove unnecessary list() from 2to3 test_constants.py -- Simple fix for netcdf4-python mask problem and make dimname and varname checks more pythonic
… containing either escape codes or unicode characters.
|
Hi Randall. Apologies for not having looked at this PR until now. For some reason I didn't receive an automatic notification in my mailbox - or if I did it must have gone straight into my junk mailbox and then been auto-deleted (our back-end systems here at work have been migrated recently and the junk mail settings are now all over the shop!) Anyhows, I'll aim to find time to look at your code changes over the next week or two. As you can tell, I've not been active on GH for some time, so it's going to take me a while to get back up to speed! |
| self.assertTrue(len(self.dataset.dimensions) == 1) | ||
| dimnames = [k for k in self.dataset.dimensions.keys()] | ||
| self.assertTrue(dimnames[0] == "dim1") | ||
| self.assertTrue('dim1' in self.dataset.dimensions.keys()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, use of 'in' is the better idiom. Plus, the keys() method is redundant in both the original and new statements.
| self.assertTrue(len(self.dataset.variables) == 1) | ||
| varnames = [k for k in self.dataset.variables.keys()] | ||
| self.assertTrue(varnames[0] == "var1") | ||
| self.assertTrue("var1" in self.dataset.variables.keys()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, use of 'in' is the better idiom. Plus, the keys() method is redundant in both the original and new statements.
|
@randallpittman Thanks for identifying and implementing the workaround for the NETCDF_CLASSIC bug, and for spotting the handful of occurrences of the now-deprecated |
Addresses issue #21.
As a side note, both Python 2 and 3 fail
test_constants.pywith netcdf4-python v1.4.2, as there's a bug where NETCDF3_CLASSIC files won't mask fill values unless the _FillValue attribute is explicitly set. Adding this line to the CDL intest_constants.pyallows all tests to pass (the actual value isn't important for the test):Change list:
longvs.int,printfunction, exceptionsas0oint_valtolong_val