Skip to content

Commit

Permalink
Add regression tests
Browse files Browse the repository at this point in the history
  • Loading branch information
roberthdevries committed Jun 10, 2022
1 parent 1457fea commit 6f51d22
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions pandas/tests/test_take.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

from pandas._libs import iNaT

import pandas as pd
import pandas._testing as tm
import pandas.core.algorithms as algos
from pandas.core.array_algos.take import _take_nd_ndarray


@pytest.fixture(params=[True, False])
Expand Down Expand Up @@ -332,3 +334,25 @@ def test_take_coerces_list(self):
result = algos.take(arr, [0, 0])
expected = np.array([1, 1])
tm.assert_numpy_array_equal(result, expected)


class TestTakeNumpyNull:
# GH 46848

def test_take_2d_axis0_object_object(self):
arr = np.array([[None]], dtype=object)
indexer = np.array([0])
axis = 1
fill_value = None
allow_fill = False

result = _take_nd_ndarray(arr, indexer, axis, fill_value, allow_fill)
assert result == [[None]]
arr2 = np.empty_like(arr)
result2 = _take_nd_ndarray(arr2, indexer, axis, fill_value, allow_fill)
assert result2 == [[None]]

def test_take_2d_axis1_object_object(self):
df = pd.DataFrame(np.empty((1, 1), dtype=object))
df[0] = np.empty_like(df[0])
df[[0]]

0 comments on commit 6f51d22

Please sign in to comment.