MCPcopy Create free account
hub / github.com/open-mmlab/mmengine / TmpObjectWithoutCat

Class TmpObjectWithoutCat

tests/test_structures/test_instance_data.py:48–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46
47
48class TmpObjectWithoutCat:
49
50 def __init__(self, tmp) -> None:
51 assert isinstance(tmp, list)
52 if len(tmp) > 0:
53 for t in tmp:
54 assert isinstance(t, list)
55 self.tmp = tmp
56
57 def __len__(self):
58 return len(self.tmp)
59
60 def __getitem__(self, item):
61 if isinstance(item, int):
62 if item >= len(self) or item < -len(self): # type:ignore
63 raise IndexError(f'Index {item} out of range!')
64 else:
65 # keep the dimension
66 item = slice(item, None, len(self))
67 return TmpObjectWithoutCat(self.tmp[item])
68
69 def __repr__(self):
70 return str(self.tmp)
71
72
73class TestInstanceData(TestCase):

Callers 3

__getitem__Method · 0.85
test_getitemMethod · 0.85
test_catMethod · 0.85

Calls

no outgoing calls

Tested by 3

__getitem__Method · 0.68
test_getitemMethod · 0.68
test_catMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…