(self, arr, fn)
| 87 | """ |
| 88 | |
| 89 | def __init__(self, arr, fn) -> None: |
| 90 | # self.orig_arr = arr |
| 91 | self.size = len(arr) |
| 92 | arr = list(enumerate(arr)) |
| 93 | |
| 94 | def group_return_dict(arr, fn): |
| 95 | res = collections.defaultdict(list) |
| 96 | |
| 97 | for ob in arr: |
| 98 | res[fn(ob)].append(ob) |
| 99 | return res |
| 100 | |
| 101 | arr = group_return_dict(arr, lambda x: fn(x[1])) |
| 102 | |
| 103 | # self.arr has format Dict[Tuple[int, <entry from orig. arr>]] |
| 104 | self.arr = arr |
| 105 | self._grouped = None |
| 106 | |
| 107 | def get_grouped(self): |
| 108 | # return the contents but not indices for our grouped dict. |
nothing calls this directly
no outgoing calls
no test coverage detected