MCPcopy Create free account
hub / github.com/PAIR-code/lit / __init__

Method __init__

lit_nlp/api/dataset.py:284–309  ·  view source on GitHub ↗
(
      self,
      *args,
      id_fn: Optional[IdFnType] = None,
      indexed_examples: Optional[list[IndexedInput]] = None,
      **kw,
  )

Source from the content-addressed store, hash-verified

282 return indexed
283
284 def __init__(
285 self,
286 *args,
287 id_fn: Optional[IdFnType] = None,
288 indexed_examples: Optional[list[IndexedInput]] = None,
289 **kw,
290 ):
291 # The base Dataset class will initialize self._examples in this call to
292 # super().__init__(), which may or may not include the _id and _meta fields.
293 super().__init__(*args, **kw)
294 self.id_fn = id_fn if id_fn is not None else input_hash
295
296 if indexed_examples:
297 self._indexed_examples = indexed_examples
298 # Ensure that all indexed exampls provide a readonly view of their data.
299 for ie in self._indexed_examples:
300 if not isinstance((ie_data := ie['data']), types.MappingProxyType):
301 ie['data'] = self._normalize_example(ie_data, ie['id'], ie['meta'])
302 else:
303 self._indexed_examples = self.index_inputs(self._examples)
304
305 self._examples = [
306 self._normalize_example(ex['data'], ex['id'], ex.get('meta', {}))
307 for ex in self._indexed_examples
308 ]
309 self._index = {ex['id']: ex for ex in self._indexed_examples}
310
311 @property
312 def slice(self):

Callers

nothing calls this directly

Calls 4

_normalize_exampleMethod · 0.95
index_inputsMethod · 0.95
getMethod · 0.80
__init__Method · 0.45

Tested by

no test coverage detected