MCPcopy Create free account
hub / github.com/Lauriat/funct / removeByIndex

Method removeByIndex

funct/Array.py:431–455  ·  view source on GitHub ↗

Removes the value at specified index or indices.

(self, b, inplace=False)

Source from the content-addressed store, hash-verified

429 return self
430
431 def removeByIndex(self, b, inplace=False):
432 """ Removes the value at specified index or indices. """
433 a = self if inplace else self.copy()
434 if isinstance(b, Iterable):
435 try:
436 c = 0
437 for i in b:
438 a.pop(i - c)
439 c += 1
440 except TypeError:
441 raise TypeError(
442 "{} object cannot be interpreted as an integer".format(
443 type(i).__name__
444 )
445 ) from None
446 else:
447 try:
448 a.pop(b)
449 except TypeError:
450 raise TypeError(
451 "{} object cannot be interpreted as an integer".format(
452 type(b).__name__
453 )
454 ) from None
455 return a
456
457 def removeByIndex_(self, b):
458 """ Removes the value at specified index or indices in-place. """

Callers 2

testMethod · 0.95
test_errsMethod · 0.80

Calls 1

copyMethod · 0.95

Tested by 2

testMethod · 0.76
test_errsMethod · 0.64