Skip to content
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
1 change: 1 addition & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Bug fixes

- Aggregation functions now correctly skip ``NaN`` for data for ``complex128``
dtype (:issue:`554`).
- Fixed indexing 0d arrays with unicode dtype (:issue:`568`).

v0.6.0 (21 August 2015)
-----------------------
Expand Down
3 changes: 2 additions & 1 deletion xray/core/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ def _as_compatible_data(data, fastpath=False):
data = np.timedelta64(getattr(data, 'value', data), 'ns')

if (not hasattr(data, 'dtype') or not hasattr(data, 'shape')
or isinstance(data, (np.string_, np.datetime64, np.timedelta64))):
or isinstance(data, (np.string_, np.unicode_,
np.datetime64, np.timedelta64))):
# data must be ndarray-like
data = np.asarray(data)

Expand Down
9 changes: 9 additions & 0 deletions xray/test/test_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,15 @@ def test_index_0d_numpy_string(self):
v = Variable([], np.string_('asdf'))
self.assertVariableIdentical(v[()], v)

v = Variable([], np.unicode_(u'asdf'))
self.assertVariableIdentical(v[()], v)

def test_indexing_0d_unicode(self):
# regression test for GH568
actual = Variable(('x'), [u'tmax'])[0][()]
expected = Variable((), u'tmax')
self.assertVariableIdentical(actual, expected)

def test_transpose(self):
v = Variable(['time', 'x'], self.d)
v2 = Variable(['x', 'time'], self.d.T)
Expand Down