MCPcopy Create free account
hub / github.com/numpy/numpy / npy_aforce_collapse

Function npy_aforce_collapse

numpy/core/src/npysort/timsort.cpp:2660–2704  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2658}
2659
2660static int
2661npy_aforce_collapse(char *arr, npy_intp *tosort, run *stack,
2662 npy_intp *stack_ptr, buffer_intp *buffer, size_t len,
2663 PyArray_CompareFunc *cmp, PyArrayObject *py_arr)
2664{
2665 int ret;
2666 npy_intp top = *stack_ptr;
2667
2668 while (2 < top) {
2669 if (stack[top - 3].l <= stack[top - 1].l) {
2670 ret = npy_amerge_at(arr, tosort, stack, top - 3, buffer, len, cmp,
2671 py_arr);
2672
2673 if (NPY_UNLIKELY(ret < 0)) {
2674 return ret;
2675 }
2676
2677 stack[top - 3].l += stack[top - 2].l;
2678 stack[top - 2] = stack[top - 1];
2679 --top;
2680 }
2681 else {
2682 ret = npy_amerge_at(arr, tosort, stack, top - 2, buffer, len, cmp,
2683 py_arr);
2684
2685 if (NPY_UNLIKELY(ret < 0)) {
2686 return ret;
2687 }
2688
2689 stack[top - 2].l += stack[top - 1].l;
2690 --top;
2691 }
2692 }
2693
2694 if (1 < top) {
2695 ret = npy_amerge_at(arr, tosort, stack, top - 2, buffer, len, cmp,
2696 py_arr);
2697
2698 if (NPY_UNLIKELY(ret < 0)) {
2699 return ret;
2700 }
2701 }
2702
2703 return 0;
2704}
2705
2706NPY_NO_EXPORT int
2707npy_atimsort(void *start, npy_intp *tosort, npy_intp num, void *varr)

Callers 1

npy_atimsortFunction · 0.85

Calls 1

npy_amerge_atFunction · 0.85

Tested by

no test coverage detected