Skip to content

BUG: ensure xray works with pandas 0.17.0 #569

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

Merged
merged 6 commits into from
Sep 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ matrix:
- libnetcdf-dev
env: UPDATE_ENV="conda install cython && pip install https://github.com/Unidata/netcdf4-python/archive/master.zip"
- python: 2.7
env: UPDATE_ENV="pip install toolz https://github.com/ContinuumIO/dask/archive/master.zip"
env: UPDATE_ENV="pip install toolz https://github.com/blaze/dask/archive/master.zip"
- python: 2.7
env: UPDATE_ENV="conda remove pandas && conda install cython && pip install https://github.com/pydata/pandas/archive/master.zip"
allow_failures:
- python: 2.7
env: UPDATE_ENV="pip install pydap"
Expand All @@ -44,7 +46,9 @@ matrix:
- libnetcdf-dev
env: UPDATE_ENV="conda install cython && pip install https://github.com/Unidata/netcdf4-python/archive/master.zip"
- python: 2.7
env: UPDATE_ENV="pip install toolz https://github.com/ContinuumIO/dask/archive/master.zip"
env: UPDATE_ENV="pip install toolz https://github.com/blaze/dask/archive/master.zip"
- python: 2.7
env: UPDATE_ENV="conda remove pandas && conda install cython && pip install https://github.com/pydata/pandas/archive/master.zip"

before_install:
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
Expand Down
3 changes: 3 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ Enhancements
Bug fixes
~~~~~~~~~

- Forwards compatibility with the next release of changes (v0.17.0).
We were using some internal pandas routines for datetime conversion, which
unfortunately have now changed upstream (:issue:`569`).
- Aggregation functions now correctly skip ``NaN`` for data for ``complex128``
dtype (:issue:`554`).
- Fixed indexing 0d arrays with unicode dtype (:issue:`568`).
Expand Down
11 changes: 2 additions & 9 deletions xray/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,13 +418,6 @@ def _maybe_promote(dtype):

def _possibly_convert_objects(values):
"""Convert arrays of datetime.datetime and datetime.timedelta objects into
datetime64 and timedelta64
datetime64 and timedelta64, according to the pandas convention.
"""
try:
converter = functools.partial(pd.core.common._possibly_convert_objects,
convert_numeric=False)
except AttributeError:
# our fault for using a private pandas API that has gone missing
# this should do the same coercion (though it will be slower)
converter = lambda x: np.asarray(pd.Series(x))
return converter(values.ravel()).reshape(values.shape)
return np.asarray(pd.Series(values.ravel())).reshape(values.shape)
8 changes: 4 additions & 4 deletions xray/core/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ def _as_compatible_data(data, fastpath=False):
data = np.asarray(data)

if isinstance(data, np.ndarray):
data = common._possibly_convert_objects(data)
if data.dtype.kind == 'M':
# TODO: automatically cast arrays of datetime objects as well
if data.dtype.kind == 'O':
data = common._possibly_convert_objects(data)
elif data.dtype.kind == 'M':
data = np.asarray(data, 'datetime64[ns]')
if data.dtype.kind == 'm':
elif data.dtype.kind == 'm':
data = np.asarray(data, 'timedelta64[ns]')

return _maybe_wrap_data(data)
Expand Down
10 changes: 6 additions & 4 deletions xray/test/test_dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,14 @@ def test_concat(self):

def test_missing_methods(self):
v = self.lazy_var
with self.assertRaisesRegexp(NotImplementedError, 'dask'):
v.conj()
with self.assertRaisesRegexp(NotImplementedError, 'dask'):
try:
v.argsort()
with self.assertRaisesRegexp(NotImplementedError, 'dask'):
except NotImplementedError as err:
self.assertIn('dask', str(err))
try:
v[0].item()
except NotImplementedError as err:
self.assertIn('dask', str(err))

def test_ufuncs(self):
u = self.eager_var
Expand Down