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

Most of Python 3 support #113

Merged
merged 44 commits into from
May 9, 2014
Merged

Most of Python 3 support #113

merged 44 commits into from
May 9, 2014

Conversation

takluyver
Copy link
Member

This isn't entirely finished, but I need to stop working on it for a bit, and I think enough of it is ready to be reviewed. The core code is passing its tests; the remaining failures are all in talking to the Scipy and netCDF4 backends. I also have PRs open against Scipy (scipy/scipy#3617) and netCDF4 (Unidata/netcdf4-python#252) to fix bugs I've encountered there.

Particular issues that came up:

  • There were quite a few circular imports. For now, I've fudged these to work rather than trying to reorganise the code.
  • isinstance(x, int) doesn't reliably catch numpy integer types - see e.g. numpy.int64 is not instance of int numpy/numpy#2951. I changed several such cases to isinstance(x, (int, np.integer)).

self.assertTrue(data_allclose_or_equiv(v1.values, v2.values,
rtol=rtol, atol=atol))
assert data_allclose_or_equiv(v1.values, v2.values, rtol=rtol, atol=atol),\
(repr(v1.values), repr(v2.values))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes like this are just to show the values causing a failure.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Didn't read the comment when I modified this before.
@shoyer shoyer added this to the 0.2 milestone May 6, 2014
@shoyer shoyer mentioned this pull request May 6, 2014
@shoyer
Copy link
Member

shoyer commented May 6, 2014

This looks really awesome -- I will take a more careful look tonight. It would be helpful if you could update .travis.yml to also test against Python 3 just so it is more obvious which tests are failing.

I'm OK potentially merging this even if a few tests IO related are still failing in Python 3. It's pretty obvious that the NetCDF libraries have not been very heavily tested used with Python 3, and I probably have more context to resolve those issues than you do.

@takluyver
Copy link
Member Author

OK, let's see how that goes.

@shoyer
Copy link
Member

shoyer commented May 6, 2014

Looks like Pydap doesn't support Python 3 yet: pydap/pydap#7

@takluyver
Copy link
Member Author

OK, I've excluded that combination from Travis.

self.ds = scipy.io.netcdf.netcdf_file(
filename_or_obj, mode=mode, mmap=mmap, version=version)

def open_store_variable(self, var):
return xray.Variable(var.dimensions, var.data, var._attributes)
return xray.Variable(var.dimensions, _decode_string_data(var.data), \
OrderedDict((k,_decode_string(v)) for (k,v) in iteritems(var._attributes)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should probably be a _decode_attrs helper function.

As a minor style point: I don't think the \ is necessary.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I've called it _decode_values instead because it doesn't need to know what type of dict it's passed.

@shoyer
Copy link
Member

shoyer commented May 9, 2014

This looks very nice, I only have a few minor complaints which I will fix up before merging.

data = DecodedCFDatetimeArray(data, units, calendar)
if 'units' in attributes:
units = attributes['units']
if isinstance(units, bytes):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it would be cleaner to simply ensure that all strings in attributes are unicode in the backends instead of doing it here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any way a bytes attribute can sneak through? I'm guessing not, since you fixed the scipy backend already.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a feeling that I changed this before I worked out the issues with the Scipy backend. I'll have a go at changing it back and see what might break.

@takluyver
Copy link
Member Author

Thanks, I've applied all of your suggestions.

shoyer added a commit that referenced this pull request May 9, 2014
Most of Python 3 support. I'll work on adding the rest later.
@shoyer shoyer merged commit b48f1ef into pydata:master May 9, 2014
@shoyer shoyer modified the milestones: 0.1.1, 0.2 May 20, 2014
keewis pushed a commit to keewis/xarray that referenced this pull request Jan 17, 2024
* fix version

* Update conf.py
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.

None yet

2 participants