def test_take_fill_raise(data_before, positions_before, indices, e): with pytest.raises(e): take( data=data_before, positions=positions_before, indices=indices, allow_fill=True, fill_value=np.nan, )
def test_take_no_fill_raise(data_before, positions_before, indices): with pytest.raises(IndexError): take( data=data_before, positions=positions_before, indices=indices, allow_fill=False, fill_value=None, )
def test_take_fill_raise(data_before: np.ndarray, positions_before: np.ndarray, indices: np.ndarray, e: type) -> None: with pytest.raises(e): take( data=data_before, positions=positions_before, indices=indices, allow_fill=True, fill_value=np.nan, )
def test_take_raises_non_empty_take(indices, allow_fill): data = np.array([], dtype=POSITIONS_DTYPE) positions = np.array([], dtype=np.float32) with pytest.raises(IndexError, match="cannot do a non-empty take"): take( data=data, positions=positions, indices=indices, allow_fill=allow_fill, fill_value=np.nan, )
def test_take_fill_ok(data_before, positions_before, indices, data_after, positions_after): data_actual, positions_actual = take( data=data_before, positions=positions_before, indices=indices, allow_fill=True, fill_value=np.nan, ) npt.assert_array_equal(data_actual, data_after) npt.assert_array_equal(positions_actual, positions_after)
def test_take_fill_ok( data_before: np.ndarray, positions_before: np.ndarray, indices: np.ndarray, data_after: np.ndarray, positions_after: np.ndarray, ) -> None: data_actual, positions_actual = take( data=data_before, positions=positions_before, indices=indices, allow_fill=True, fill_value=np.nan, ) npt.assert_array_equal(data_actual, data_after) assert data_actual.dtype == data_after.dtype npt.assert_array_equal(positions_actual, positions_after) assert positions_actual.dtype == positions_after.dtype