MCPcopy Index your code
hub / github.com/dask/dask / searchsorted

Function searchsorted

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

Source from the content-addressed store, hash-verified

809
810@derived_from(np)
811def 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
851def _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

Used in the wild real call sites across dependent graphs

searching dependent graphs…