MCPcopy
hub / github.com/more-itertools/more-itertools / index

Method index

more_itertools/more.py:2421–2433  ·  view source on GitHub ↗
(self, value)

Source from the content-addressed store, hash-verified

2419 return int(value in self)
2420
2421 def index(self, value):
2422 if self._growing:
2423 if self._start <= value < self._stop:
2424 q, r = divmod(value - self._start, self._step)
2425 if r == self._zero:
2426 return int(q)
2427 else:
2428 if self._start >= value > self._stop:
2429 q, r = divmod(self._start - value, -self._step)
2430 if r == self._zero:
2431 return int(q)
2432
2433 raise ValueError(f"{value} is not in numeric range")
2434
2435 def _get_by_index(self, i):
2436 if i < 0:

Callers 5

test_indexMethod · 0.80
test_abc_methodsMethod · 0.80
distinct_permutationsFunction · 0.80
product_indexFunction · 0.80
permutation_indexFunction · 0.80

Calls

no outgoing calls

Tested by 2

test_indexMethod · 0.64
test_abc_methodsMethod · 0.64