MCPcopy Create free account
hub / github.com/OpenSparseLLMs/MoM / __init__

Method __init__

lm-eval-harness/lm_eval/utils.py:170–185  ·  view source on GitHub ↗

Reorder an array according to some function Args: arr (List[Any]): The initial array fn (Callable[[Any], Any]): A function to determine the priority of elements

(self, arr: List[Any], fn: Callable)

Source from the content-addressed store, hash-verified

168
169class Reorderer:
170 def __init__(self, arr: List[Any], fn: Callable) -> None:
171 """Reorder an array according to some function
172
173 Args:
174 arr (List[Any]): The initial array
175 fn (Callable[[Any], Any]): A function to determine the priority of elements
176 """
177 self.size = len(arr)
178 arr = list(enumerate(arr))
179 arr = group(arr, lambda x: fn(x[1]))
180 # arr = [([y[0] for y in x], x[0][1]) for x in arr]
181 # TODO: overhaul reorderer. It currently grouped requests by content but we don't want this
182 arr = [([y[0]], x[0][1]) for x in arr for y in x]
183 arr.sort(key=lambda x: fn(x[1]))
184
185 self.arr = arr
186
187 def get_reordered(self):
188 """Gets the reordered array

Callers

nothing calls this directly

Calls 1

groupFunction · 0.85

Tested by

no test coverage detected