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
7 changes: 2 additions & 5 deletions xarray/coding/cftimeindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,5 @@ def _parse_array_of_cftime_strings(strings, date_type):
-------
np.array
"""
if strings.ndim == 0:
return np.array(_parse_iso8601_without_reso(date_type, strings.item()))
else:
return np.array([_parse_iso8601_without_reso(date_type, s)
for s in strings])
return np.array([_parse_iso8601_without_reso(date_type, s)
for s in strings.ravel()]).reshape(strings.shape)
8 changes: 5 additions & 3 deletions xarray/tests/test_cftimeindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,9 +689,11 @@ def test_cftimeindex_shift_invalid_freq():
def test_parse_array_of_cftime_strings():
from cftime import DatetimeNoLeap

strings = np.array(['2000-01-01', '2000-01-02'])
expected = np.array([DatetimeNoLeap(2000, 1, 1),
DatetimeNoLeap(2000, 1, 2)])
strings = np.array([['2000-01-01', '2000-01-02'],
['2000-01-03', '2000-01-04']])
expected = np.array(
[[DatetimeNoLeap(2000, 1, 1), DatetimeNoLeap(2000, 1, 2)],
[DatetimeNoLeap(2000, 1, 3), DatetimeNoLeap(2000, 1, 4)]])

result = _parse_array_of_cftime_strings(strings, DatetimeNoLeap)
np.testing.assert_array_equal(result, expected)
Expand Down