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

Method _reorder

lm-eval-harness/lm_eval/models/utils.py:407–419  ·  view source on GitHub ↗

Reorders the elements in the array based on the sorting function. Parameters: - arr (Union[List, Tuple[Tuple[int, Any], ...]]): The array or iterable to be reordered. Yields: List: Yields reordered elements one by one.

(self, arr: Union[List, Tuple[Tuple[int, Any], ...]])

Source from the content-addressed store, hash-verified

405 yield from batch
406
407 def _reorder(self, arr: Union[List, Tuple[Tuple[int, Any], ...]]) -> List:
408 """
409 Reorders the elements in the array based on the sorting function.
410
411 Parameters:
412 - arr (Union[List, Tuple[Tuple[int, Any], ...]]): The array or iterable to be reordered.
413
414 Yields:
415 List: Yields reordered elements one by one.
416 """
417 arr = sorted(arr, key=lambda x: self.fn(x[1]))
418 self.reorder_indices.extend([x[0] for x in arr])
419 yield from [x[1] for x in arr]
420
421 def get_original(self, newarr: List) -> List:
422 """

Callers 1

get_batchedMethod · 0.95

Calls 1

fnMethod · 0.80

Tested by

no test coverage detected