MCPcopy
hub / github.com/numpy/numpy / _get_indexes

Function _get_indexes

numpy/lib/_function_base_impl.py:4691–4723  ·  view source on GitHub ↗

Get the valid indexes of arr neighbouring virtual_indexes. Note This is a companion function to linear interpolation of Quantiles Returns ------- (previous_indexes, next_indexes): Tuple A Tuple of virtual_indexes neighbouring indexes

(arr, virtual_indexes, valid_values_count)

Source from the content-addressed store, hash-verified

4689
4690
4691def _get_indexes(arr, virtual_indexes, valid_values_count):
4692 """
4693 Get the valid indexes of arr neighbouring virtual_indexes.
4694 Note
4695 This is a companion function to linear interpolation of
4696 Quantiles
4697
4698 Returns
4699 -------
4700 (previous_indexes, next_indexes): Tuple
4701 A Tuple of virtual_indexes neighbouring indexes
4702 """
4703 previous_indexes = floor(virtual_indexes, out=...)
4704 next_indexes = add(previous_indexes, 1, out=...)
4705 indexes_above_bounds = virtual_indexes >= valid_values_count - 1
4706 # When indexes is above max index, take the max value of the array
4707 if indexes_above_bounds.any():
4708 previous_indexes[indexes_above_bounds] = -1
4709 next_indexes[indexes_above_bounds] = -1
4710 # When indexes is below min index, take the min value of the array
4711 indexes_below_bounds = virtual_indexes < 0
4712 if indexes_below_bounds.any():
4713 previous_indexes[indexes_below_bounds] = 0
4714 next_indexes[indexes_below_bounds] = 0
4715 if np.issubdtype(arr.dtype, np.inexact):
4716 # After the sort, slices having NaNs will have for last element a NaN
4717 virtual_indexes_nans = np.isnan(virtual_indexes)
4718 if virtual_indexes_nans.any():
4719 previous_indexes[virtual_indexes_nans] = -1
4720 next_indexes[virtual_indexes_nans] = -1
4721 previous_indexes = previous_indexes.astype(np.intp)
4722 next_indexes = next_indexes.astype(np.intp)
4723 return previous_indexes, next_indexes
4724
4725
4726def _quantile(

Callers 1

_quantileFunction · 0.85

Calls 3

addFunction · 0.85
astypeMethod · 0.80
anyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…