MCPcopy Create free account
hub / github.com/tensorflow/datasets / __getitem__

Method __getitem__

tensorflow_datasets/core/splits.py:471–486  ·  view source on GitHub ↗
(self, key)

Source from the content-addressed store, hash-verified

469 self._dataset_name = dataset_name # deprecated, please don't use
470
471 def __getitem__(self, key) -> SplitInfo | SubSplitInfo:
472 if not self:
473 raise KeyError(
474 f'Trying to access `splits[{key!r}]` but `splits` is empty. '
475 'This likely indicates the dataset has not been generated yet.'
476 )
477 # 1st case: The key exists: `info.splits['train']`
478 elif str(key) in self.keys():
479 return super().__getitem__(str(key))
480 # 2nd case: Uses instructions: `info.splits['train[50%]']`
481 else:
482 instructions = _make_file_instructions(
483 split_infos=list(self.values()),
484 instruction=key,
485 )
486 return SubSplitInfo(name=key, file_instructions=instructions)
487
488 @classmethod
489 def from_proto(

Callers

nothing calls this directly

Calls 4

_make_file_instructionsFunction · 0.85
SubSplitInfoClass · 0.85
keysMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected