Skip to content

Commit

Permalink
add test for 1D object array indexing (#2415)
Browse files Browse the repository at this point in the history
Co-authored-by: David Tremouilles <dtremoui@ouragan>
Co-authored-by: Keewis <[email protected]>
  • Loading branch information
3 people authored Apr 5, 2021
1 parent 3cbd21a commit 27ecf2d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions xarray/tests/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,3 +753,16 @@ def test_create_mask_error():
def test_posify_mask_subindexer(indices, expected):
actual = indexing._posify_mask_subindexer(indices)
np.testing.assert_array_equal(expected, actual)


def test_indexing_1d_object_array():
items = (np.arange(3), np.arange(6))
arr = DataArray(np.array(items))

actual = arr[0]

expected_data = np.empty((), dtype=object)
expected_data[()] = items[0]
expected = DataArray(expected_data)

assert [actual.data.item()] == [expected.data.item()]

0 comments on commit 27ecf2d

Please sign in to comment.