require_index#

scikitplot.rank_bm25.require_index(value, count, *, name='index')[source]#

Return value as a position valid in [0, count).

Parameters:
valueobject

Candidate position.

countint

Number of rows available.

namestr, optional

Parameter name as the calling function spells it.

Returns:
int

The validated position.

Raises:
TypeError

If the value is not an integer, or is a bool.

IndexError

If the position is negative or not below count. Negative values are refused rather than counted from the end.

Parameters:
Return type:

int

Examples

>>> require_index(2, 5)
2
>>> require_index(-1, 5)
Traceback (most recent call last):
    ...
IndexError: index -1 is outside [0, 5); negative positions are not counted from the end.