MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / getitem

Method getitem

test/sot/test_mutable_data.py:76–85  ·  view source on GitHub ↗
(self, key)

Source from the content-addressed store, hash-verified

74 return ConstVariable(proxy.original_data[key])
75
76 def getitem(self, key):
77 if isinstance(key, int):
78 res = self.proxy.get(key)
79 if isinstance(res, MutableData.Empty):
80 raise IndexError(f"Index {key} out of range")
81 return res
82 elif isinstance(key, slice):
83 return self.proxy.get_all()[key]
84 else:
85 raise TypeError(f"Invalid key type {type(key)}")
86
87 def __getitem__(self, key):
88 return self.getitem(key)

Callers 15

__getitem__Method · 0.95
popMethod · 0.95
removeMethod · 0.95
sortMethod · 0.95
test_getitemMethod · 0.95
test_getitem_slice_1Method · 0.95
test_setitemMethod · 0.95
test_setitem_slice_1Method · 0.95
test_setitem_slice_2Method · 0.95
test_delitemMethod · 0.95
test_insertMethod · 0.95
test_appendMethod · 0.95

Calls 5

IndexErrorClass · 0.85
TypeErrorClass · 0.85
typeFunction · 0.50
getMethod · 0.45
get_allMethod · 0.45

Tested by

no test coverage detected