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

Function _get_indexes

numpy/lib/function_base.py:4730–4762  ·  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

4728
4729
4730def _get_indexes(arr, virtual_indexes, valid_values_count):
4731 """
4732 Get the valid indexes of arr neighbouring virtual_indexes.
4733 Note
4734 This is a companion function to linear interpolation of
4735 Quantiles
4736
4737 Returns
4738 -------
4739 (previous_indexes, next_indexes): Tuple
4740 A Tuple of virtual_indexes neighbouring indexes
4741 """
4742 previous_indexes = np.asanyarray(np.floor(virtual_indexes))
4743 next_indexes = np.asanyarray(previous_indexes + 1)
4744 indexes_above_bounds = virtual_indexes >= valid_values_count - 1
4745 # When indexes is above max index, take the max value of the array
4746 if indexes_above_bounds.any():
4747 previous_indexes[indexes_above_bounds] = -1
4748 next_indexes[indexes_above_bounds] = -1
4749 # When indexes is below min index, take the min value of the array
4750 indexes_below_bounds = virtual_indexes < 0
4751 if indexes_below_bounds.any():
4752 previous_indexes[indexes_below_bounds] = 0
4753 next_indexes[indexes_below_bounds] = 0
4754 if np.issubdtype(arr.dtype, np.inexact):
4755 # After the sort, slices having NaNs will have for last element a NaN
4756 virtual_indexes_nans = np.isnan(virtual_indexes)
4757 if virtual_indexes_nans.any():
4758 previous_indexes[virtual_indexes_nans] = -1
4759 next_indexes[virtual_indexes_nans] = -1
4760 previous_indexes = previous_indexes.astype(np.intp)
4761 next_indexes = next_indexes.astype(np.intp)
4762 return previous_indexes, next_indexes
4763
4764
4765def _quantile(

Callers 1

_quantileFunction · 0.85

Calls 2

astypeMethod · 0.80
anyMethod · 0.45

Tested by

no test coverage detected