(a, v, side="left", sorter=None)
| 809 | |
| 810 | @derived_from(np) |
| 811 | def searchsorted(a, v, side="left", sorter=None): |
| 812 | if a.ndim != 1: |
| 813 | raise ValueError("Input array a must be one dimensional") |
| 814 | |
| 815 | if sorter is not None: |
| 816 | raise NotImplementedError( |
| 817 | "da.searchsorted with a sorter argument is not supported" |
| 818 | ) |
| 819 | |
| 820 | # call np.searchsorted for each pair of blocks in a and v |
| 821 | meta = np.searchsorted(a._meta, v._meta) |
| 822 | out = blockwise( |
| 823 | _searchsorted_block, |
| 824 | list(range(v.ndim + 1)), |
| 825 | a, |
| 826 | [0], |
| 827 | v, |
| 828 | list(range(1, v.ndim + 1)), |
| 829 | side, |
| 830 | None, |
| 831 | meta=meta, |
| 832 | adjust_chunks={0: 1}, # one row for each block in a |
| 833 | ) |
| 834 | |
| 835 | # add offsets to take account of the position of each block within the array a |
| 836 | a_chunk_sizes = array_safe((0, *a.chunks[0]), like=meta_from_array(a)) |
| 837 | a_chunk_offsets = np.cumsum(a_chunk_sizes)[:-1] |
| 838 | a_chunk_offsets = a_chunk_offsets[(Ellipsis,) + v.ndim * (np.newaxis,)] |
| 839 | a_offsets = asarray(a_chunk_offsets, chunks=1) |
| 840 | out = where(out < 0, out, out + a_offsets) |
| 841 | |
| 842 | # combine the results from each block (of a) |
| 843 | out = out.max(axis=0) |
| 844 | |
| 845 | # fix up any -1 values |
| 846 | out[out == -1] = 0 |
| 847 | |
| 848 | return out |
| 849 | |
| 850 | |
| 851 | def _linspace(bins_range): |
nothing calls this directly
no test coverage detected
searching dependent graphs…