Skip to content

CLN: remove arrmap, closes #27251 #27530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 23, 2019
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
25 changes: 0 additions & 25 deletions pandas/_libs/algos.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 3 additions & 1 deletion pandas/core/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


# --------------- #
Expand Down
6 changes: 0 additions & 6 deletions pandas/tests/test_algos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down