MCPcopy Create free account
hub / github.com/dask/dask / searchsorted

Function searchsorted

dask/array/routines.py:813–850  ·  view source on GitHub ↗
(a, v, side="left", sorter=None)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 7

array_safeFunction · 0.90
meta_from_arrayFunction · 0.90
asarrayFunction · 0.90
blockwiseFunction · 0.70
whereFunction · 0.70
cumsumMethod · 0.45
maxMethod · 0.45

Tested by

no test coverage detected