From 221aba15fe6aeed87c9b4126f6090b1dc3d7508a Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Mon, 22 Jul 2019 17:24:44 -0700 Subject: [PATCH] remove arrmap, closes #27251 --- pandas/_libs/algos.pyx | 25 ------------------------- pandas/core/algorithms.py | 4 +++- pandas/tests/test_algos.py | 6 ------ 3 files changed, 3 insertions(+), 32 deletions(-) diff --git a/pandas/_libs/algos.pyx b/pandas/_libs/algos.pyx index 0dbe525f7506e..038447ad252fe 100644 --- a/pandas/_libs/algos.pyx +++ b/pandas/_libs/algos.pyx @@ -674,31 +674,6 @@ def backfill_2d_inplace(algos_t[:, :] values, val = values[j, i] -@cython.wraparound(False) -@cython.boundscheck(False) -def arrmap(algos_t[:] index, object func): - cdef: - Py_ssize_t length = index.shape[0] - Py_ssize_t i = 0 - ndarray[object] result = np.empty(length, dtype=np.object_) - - from pandas._libs.lib import maybe_convert_objects - - for i in range(length): - result[i] = func(index[i]) - - return maybe_convert_objects(result) - - -arrmap_float64 = arrmap["float64_t"] -arrmap_float32 = arrmap["float32_t"] -arrmap_object = arrmap["object"] -arrmap_int64 = arrmap["int64_t"] -arrmap_int32 = arrmap["int32_t"] -arrmap_uint64 = arrmap["uint64_t"] -arrmap_bool = arrmap["uint8_t"] - - @cython.boundscheck(False) @cython.wraparound(False) def is_monotonic(ndarray[algos_t, ndim=1] arr, bint timelike): diff --git a/pandas/core/algorithms.py b/pandas/core/algorithms.py index 111f6bf04b523..c7230dd7385c2 100644 --- a/pandas/core/algorithms.py +++ b/pandas/core/algorithms.py @@ -1100,7 +1100,9 @@ def _get_score(at): return _get_score(q) else: q = np.asarray(q, np.float64) - return algos.arrmap_float64(q, _get_score) + result = [_get_score(x) for x in q] + result = np.array(result, dtype=np.float64) + return result # --------------- # diff --git a/pandas/tests/test_algos.py b/pandas/tests/test_algos.py index c0d73821020b5..d81ee79418e9c 100644 --- a/pandas/tests/test_algos.py +++ b/pandas/tests/test_algos.py @@ -1685,12 +1685,6 @@ def test_pad_backfill_object_segfault(): tm.assert_numpy_array_equal(result, expected) -def test_arrmap(): - values = np.array(["foo", "foo", "bar", "bar", "baz", "qux"], dtype="O") - result = libalgos.arrmap_object(values, lambda x: x in ["foo", "bar"]) - assert result.dtype == np.bool_ - - class TestTseriesUtil: def test_combineFunc(self): pass