(
self,
*args,
id_fn: Optional[IdFnType] = None,
indexed_examples: Optional[list[IndexedInput]] = None,
**kw,
)
| 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): |
nothing calls this directly
no test coverage detected