text stringlengths 24 253k | type stringclasses 1
value | start int64 67 146k | end int64 223 278k | depth int64 0 1 | filepath stringlengths 74 128 | parent_class stringclasses 1
value | class_index int64 0 271 |
|---|---|---|---|---|---|---|---|
class DatasetInfoMixin:
"""This base class exposes some attributes of DatasetInfo
at the base level of the Dataset for easy access.
"""
def __init__(self, info: DatasetInfo, split: Optional[NamedSplit]):
self._info = info
self._split = split
@property
def info(self):
""... | class_definition | 4,179 | 5,999 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/arrow_dataset.py | null | 0 |
class TensorflowDatasetMixin:
_TF_DATASET_REFS = set()
@staticmethod
def _get_output_signature(
dataset: "Dataset",
collate_fn: Callable,
collate_fn_args: dict,
cols_to_retain: Optional[List[str]] = None,
batch_size: Optional[int] = None,
num_test_batches: in... | class_definition | 6,002 | 20,798 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/arrow_dataset.py | null | 1 |
class DatasetTransformationNotAllowedError(Exception):
pass | class_definition | 20,801 | 20,864 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/arrow_dataset.py | null | 2 |
class NonExistentDatasetError(Exception):
"""Used when we expect the existence of a dataset"""
pass | class_definition | 24,928 | 25,036 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/arrow_dataset.py | null | 3 |
class Dataset(DatasetInfoMixin, IndexableMixin, TensorflowDatasetMixin):
"""A Dataset backed by an Arrow table."""
def __init__(
self,
arrow_table: Table,
info: Optional[DatasetInfo] = None,
split: Optional[NamedSplit] = None,
indices_table: Optional[Table] = None,
... | class_definition | 25,039 | 277,916 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/arrow_dataset.py | null | 4 |
class NumExamplesMismatchError(Exception):
pass | class_definition | 146,059 | 146,118 | 1 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/arrow_dataset.py | Dataset | 5 |
class Url(str):
pass | class_definition | 928 | 952 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/data_files.py | null | 6 |
class EmptyDatasetError(FileNotFoundError):
pass | class_definition | 955 | 1,007 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/data_files.py | null | 7 |
class DataFilesList(List[str]):
"""
List of data files (absolute local paths or URLs).
It has two construction methods given the user's data files patterns:
- ``from_hf_repo``: resolve patterns inside a dataset repository
- ``from_local_or_remote``: resolve patterns from a local path
Moreover, ... | class_definition | 22,243 | 25,785 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/data_files.py | null | 8 |
class DataFilesDict(Dict[str, DataFilesList]):
"""
Dict of split_name -> list of data files (absolute local paths or URLs).
It has two construction methods given the user's data files patterns :
- ``from_hf_repo``: resolve patterns inside a dataset repository
- ``from_local_or_remote``: resolve patt... | class_definition | 25,788 | 29,225 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/data_files.py | null | 9 |
class DataFilesPatternsList(List[str]):
"""
List of data files patterns (absolute local paths or URLs).
For each pattern there should also be a list of allowed extensions
to keep, or a None ot keep all the files for the pattern.
"""
def __init__(
self,
patterns: List[str],
... | class_definition | 29,228 | 31,193 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/data_files.py | null | 10 |
class DataFilesPatternsDict(Dict[str, DataFilesPatternsList]):
"""
Dict of split_name -> list of data files patterns (absolute local paths or URLs).
"""
@classmethod
def from_patterns(
cls, patterns: Dict[str, List[str]], allowed_extensions: Optional[List[str]] = None
) -> "DataFilesPat... | class_definition | 31,196 | 32,536 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/data_files.py | null | 11 |
class _BaseExamplesIterable:
"""Base class for the examples iterable used by an IterableDataset"""
def __init__(self) -> None:
self._state_dict: Optional[Union[list, dict]] = None
def __iter__(self) -> Iterator[Tuple[Key, dict]]:
"""An examples iterable should yield tuples (example_key, ex... | class_definition | 4,646 | 7,694 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/iterable_dataset.py | null | 12 |
class ExamplesIterable(_BaseExamplesIterable):
def __init__(self, generate_examples_fn: Callable[..., Tuple[Key, dict]], kwargs: dict):
super().__init__()
self.generate_examples_fn = generate_examples_fn
self.kwargs = kwargs
def _init_state_dict(self) -> dict:
self._state_dict =... | class_definition | 7,697 | 9,617 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/iterable_dataset.py | null | 13 |
class ShuffledDataSourcesExamplesIterable(ExamplesIterable):
def __init__(
self, generate_examples_fn: Callable[..., Tuple[Key, dict]], kwargs: dict, generator: np.random.Generator
):
super().__init__(generate_examples_fn, kwargs)
self.generator = deepcopy(generator)
def _init_state... | class_definition | 9,620 | 11,419 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/iterable_dataset.py | null | 14 |
class ArrowExamplesIterable(_BaseExamplesIterable):
def __init__(self, generate_tables_fn: Callable[..., Tuple[Key, pa.Table]], kwargs: dict):
super().__init__()
self.generate_tables_fn = generate_tables_fn
self.kwargs = kwargs
@property
def iter_arrow(self):
return self._it... | class_definition | 11,422 | 14,924 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/iterable_dataset.py | null | 15 |
class ShuffledDataSourcesArrowExamplesIterable(ArrowExamplesIterable):
def __init__(
self,
generate_tables_fn: Callable[..., Tuple[Key, pa.Table]],
kwargs: dict,
generator: np.random.Generator,
):
super().__init__(generate_tables_fn, kwargs)
self.generator = deepc... | class_definition | 14,927 | 18,412 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/iterable_dataset.py | null | 16 |
class RebatchedArrowExamplesIterable(_BaseExamplesIterable):
def __init__(self, ex_iterable: _BaseExamplesIterable, batch_size: Optional[int], drop_last_batch: bool = False):
super().__init__()
self.ex_iterable = ex_iterable
self.batch_size = batch_size
self.drop_last_batch = drop_la... | class_definition | 18,415 | 24,972 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/iterable_dataset.py | null | 17 |
class SelectColumnsIterable(_BaseExamplesIterable):
def __init__(self, ex_iterable: _BaseExamplesIterable, column_names: List[str]):
super().__init__()
self.ex_iterable = ex_iterable
self.column_names = column_names
@property
def iter_arrow(self):
if self.ex_iterable.iter_ar... | class_definition | 24,975 | 26,567 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/iterable_dataset.py | null | 18 |
class StepExamplesIterable(_BaseExamplesIterable):
def __init__(self, ex_iterable: _BaseExamplesIterable, step: int, offset: int):
super().__init__()
self.ex_iterable = ex_iterable
self.step = step
self.offset = offset
# TODO(QL): implement iter_arrow
@property
def i... | class_definition | 26,570 | 28,065 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/iterable_dataset.py | null | 19 |
class CyclingMultiSourcesExamplesIterable(_BaseExamplesIterable):
def __init__(
self,
ex_iterables: List[_BaseExamplesIterable],
stopping_strategy: Literal["first_exhausted", "all_exhausted"] = "first_exhausted",
):
super().__init__()
self.ex_iterables = ex_iterables
... | class_definition | 28,068 | 32,855 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/iterable_dataset.py | null | 20 |
class VerticallyConcatenatedMultiSourcesExamplesIterable(_BaseExamplesIterable):
"""
VerticallyConcatenatedMultiSourcesExamplesIterable simply chains the input iterables.
It doesn't require the examples iterables to always yield the same columns.
Instead, this is handled by the `IterableDataset` class o... | class_definition | 32,858 | 36,108 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/iterable_dataset.py | null | 21 |
class HorizontallyConcatenatedMultiSourcesExamplesIterable(_BaseExamplesIterable):
"""
HorizontallyConcatenatedMultiSourcesExamplesIterable merges examples together for the input list of iterables.
It also checks that there are no duplicate columns (otherwise we don't know which one to keep).
This check... | class_definition | 36,561 | 39,713 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/iterable_dataset.py | null | 22 |
class RandomlyCyclingMultiSourcesExamplesIterable(CyclingMultiSourcesExamplesIterable):
def __init__(
self,
ex_iterables: List[_BaseExamplesIterable],
generator: np.random.Generator,
probabilities: Optional[List[float]] = None,
stopping_strategy: Literal["first_exhausted", "a... | class_definition | 39,716 | 43,531 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/iterable_dataset.py | null | 23 |
class MappedExamplesIterable(_BaseExamplesIterable):
def __init__(
self,
ex_iterable: _BaseExamplesIterable,
function: Callable,
with_indices: bool = False,
input_columns: Optional[List[str]] = None,
batched: bool = False,
batch_size: Optional[int] = 1000,
... | class_definition | 43,534 | 57,830 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/iterable_dataset.py | null | 24 |
class FilteredExamplesIterable(_BaseExamplesIterable):
def __init__(
self,
ex_iterable: _BaseExamplesIterable,
function: Callable,
with_indices: bool = False,
input_columns: Optional[List[str]] = None,
batched: bool = False,
batch_size: Optional[int] = 1000,
... | class_definition | 57,833 | 68,029 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/iterable_dataset.py | null | 25 |
class BufferShuffledExamplesIterable(_BaseExamplesIterable):
def __init__(self, ex_iterable: _BaseExamplesIterable, buffer_size: int, generator: np.random.Generator):
super().__init__()
self.ex_iterable = ex_iterable
self.buffer_size = buffer_size
self.generator = generator
#... | class_definition | 68,032 | 71,070 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/iterable_dataset.py | null | 26 |
class SkipExamplesIterable(_BaseExamplesIterable):
def __init__(
self,
ex_iterable: _BaseExamplesIterable,
n: int,
block_sources_order_when_shuffling: bool = True,
split_when_sharding: bool = True,
):
super().__init__()
self.ex_iterable = ex_iterable
... | class_definition | 71,073 | 73,699 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/iterable_dataset.py | null | 27 |
class TakeExamplesIterable(_BaseExamplesIterable):
def __init__(
self,
ex_iterable: _BaseExamplesIterable,
n: int,
block_sources_order_when_shuffling: bool = True,
split_when_sharding: bool = True,
):
super().__init__()
self.ex_iterable = ex_iterable
... | class_definition | 73,702 | 76,673 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/iterable_dataset.py | null | 28 |
class FormattingConfig:
format_type: Optional[str]
def __post_init__(self):
if self.format_type == "pandas":
raise NotImplementedError(
"The 'pandas' formatting is not implemented for iterable datasets. You can use 'numpy' or 'arrow' instead."
) | class_definition | 77,927 | 78,229 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/iterable_dataset.py | null | 29 |
class FormattedExamplesIterable(_BaseExamplesIterable):
def __init__(
self,
ex_iterable: _BaseExamplesIterable,
formatting: Optional[FormattingConfig],
features: Optional[Features],
token_per_repo_id: Dict[str, Union[str, bool, None]],
):
super().__init__()
... | class_definition | 78,232 | 82,283 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/iterable_dataset.py | null | 30 |
class ShufflingConfig:
generator: np.random.Generator
_original_seed: Optional[int] = None | class_definition | 82,297 | 82,395 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/iterable_dataset.py | null | 31 |
class DistributedConfig:
rank: int
world_size: int | class_definition | 82,409 | 82,467 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/iterable_dataset.py | null | 32 |
class IterableDataset(DatasetInfoMixin):
"""A Dataset backed by an iterable."""
def __init__(
self,
ex_iterable: _BaseExamplesIterable,
info: Optional[DatasetInfo] = None,
split: Optional[NamedSplit] = None,
formatting: Optional[FormattingConfig] = None,
shufflin... | class_definition | 83,166 | 142,854 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/iterable_dataset.py | null | 33 |
class DatasetDict(dict):
"""A dictionary (dict of str: datasets.Dataset) with dataset transforms methods (map, filter, etc.)"""
def _check_values_type(self):
for dataset in self.values():
if not isinstance(dataset, Dataset):
raise TypeError(f"Values in `DatasetDict` should b... | class_definition | 1,100 | 83,252 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/dataset_dict.py | null | 34 |
class IterableDatasetDict(dict):
def __repr__(self):
repr = "\n".join([f"{k}: {v}" for k, v in self.items()])
repr = re.sub(r"^", " " * 4, repr, 0, re.M)
return f"IterableDatasetDict({{\n{repr}\n}})"
def with_format(
self,
type: Optional[str] = None,
) -> "IterableDa... | class_definition | 83,255 | 105,395 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/dataset_dict.py | null | 35 |
class _TempCacheDir:
"""
A temporary directory for storing cached Arrow files with a cleanup that frees references to the Arrow files
before deleting the directory itself to avoid permission errors on Windows.
"""
def __init__(self):
self.name = tempfile.mkdtemp(prefix=config.TEMP_CACHE_DIR... | class_definition | 1,190 | 2,103 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/fingerprint.py | null | 36 |
class Hasher:
"""Hasher that accepts python objects as inputs."""
dispatch: Dict = {}
def __init__(self):
self.m = xxhash.xxh64()
@classmethod
def hash_bytes(cls, value: Union[bytes, List[bytes]]) -> str:
value = [value] if isinstance(value, bytes) else value
m = xxhash.xx... | class_definition | 6,698 | 7,515 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/fingerprint.py | null | 37 |
class SchemaInferenceError(ValueError):
pass | class_definition | 3,235 | 3,283 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/arrow_writer.py | null | 38 |
class TypedSequence:
"""
This data container generalizes the typing when instantiating pyarrow arrays, tables or batches.
More specifically it adds several features:
- Support extension types like ``datasets.features.Array2DExtensionType``:
By default pyarrow arrays don't return extension array... | class_definition | 3,286 | 13,936 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/arrow_writer.py | null | 39 |
class OptimizedTypedSequence(TypedSequence):
def __init__(
self,
data,
type: Optional[FeatureType] = None,
try_type: Optional[FeatureType] = None,
col: Optional[str] = None,
optimized_int_type: Optional[FeatureType] = None,
):
optimized_int_type_by_col = {... | class_definition | 13,939 | 14,847 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/arrow_writer.py | null | 40 |
class ArrowWriter:
"""Shuffles and writes Examples to Arrow files."""
_WRITER_CLASS = pa.RecordBatchStreamWriter
def __init__(
self,
schema: Optional[pa.Schema] = None,
features: Optional[Features] = None,
path: Optional[str] = None,
stream: Optional[pa.NativeFile] ... | class_definition | 14,850 | 29,359 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/arrow_writer.py | null | 41 |
class ParquetWriter(ArrowWriter):
_WRITER_CLASS = pq.ParquetWriter | class_definition | 29,362 | 29,432 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/arrow_writer.py | null | 42 |
class DatasetNotOnHfGcsError(ConnectionError):
"""When you can't get the dataset from the Hf google cloud storage"""
pass | class_definition | 1,733 | 1,863 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/arrow_reader.py | null | 43 |
class MissingFilesOnHfGcsError(ConnectionError):
"""When some files are missing on the Hf oogle cloud storage"""
pass | class_definition | 1,866 | 1,992 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/arrow_reader.py | null | 44 |
class FileInstructions:
"""The file instructions associated with a split ReadInstruction.
Attributes:
num_examples: `int`, The total number of examples
file_instructions: List[dict(filename, skip, take)], the files information.
The filenames contains the relative path, not absolute.... | class_definition | 2,019 | 2,491 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/arrow_reader.py | null | 45 |
class BaseReader:
"""
Build a Dataset object out of Instruction instance(s).
"""
def __init__(self, path: str, info: Optional["DatasetInfo"]):
"""Initializes ArrowReader.
Args:
path (str): path where tfrecords are stored.
info (DatasetInfo): info about the datas... | class_definition | 5,799 | 10,729 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/arrow_reader.py | null | 46 |
class ArrowReader(BaseReader):
"""
Build a Dataset object out of Instruction instance(s).
This Reader uses either memory mapping or file descriptors (in-memory) on arrow files.
"""
def __init__(self, path: str, info: Optional["DatasetInfo"]):
"""Initializes ArrowReader.
Args:
... | class_definition | 10,732 | 12,461 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/arrow_reader.py | null | 47 |
class ParquetReader(BaseReader):
"""
Build a Dataset object out of Instruction instance(s).
This Reader uses memory mapping on parquet files.
"""
def __init__(self, path: str, info: Optional["DatasetInfo"]):
"""Initializes ParquetReader.
Args:
path (str): path where tfr... | class_definition | 12,464 | 13,736 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/arrow_reader.py | null | 48 |
class _AbsoluteInstruction:
"""A machine friendly slice: defined absolute positive boundaries."""
splitname: str
from_: int # uint (starting index).
to: int # uint (ending index). | class_definition | 13,763 | 13,961 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/arrow_reader.py | null | 49 |
class _RelativeInstruction:
"""Represents a single parsed slicing instruction, can use % and negatives."""
splitname: str
from_: Optional[int] = None # int (starting index) or None if no lower boundary.
to: Optional[int] = None # int (ending index) or None if no upper boundary.
unit: Optional[str... | class_definition | 13,988 | 15,346 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/arrow_reader.py | null | 50 |
class ReadInstruction:
"""Reading instruction for a dataset.
Examples::
# The following lines are equivalent:
ds = datasets.load_dataset('mnist', split='test[:33%]')
ds = datasets.load_dataset('mnist', split=datasets.ReadInstruction.from_spec('test[:33%]'))
ds = datasets.load_dataset('... | class_definition | 17,502 | 25,130 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/arrow_reader.py | null | 51 |
class InvalidConfigName(ValueError):
pass | class_definition | 3,042 | 3,087 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/builder.py | null | 52 |
class BuilderConfig:
"""Base class for `DatasetBuilder` data configuration.
`DatasetBuilder` subclasses with data configuration options should subclass
`BuilderConfig` and add their own properties.
Attributes:
name (`str`, defaults to `default`):
The name of the configuration.
... | class_definition | 3,101 | 8,676 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/builder.py | null | 53 |
class DatasetBuilder:
"""Abstract base class for all datasets.
`DatasetBuilder` has 3 key methods:
- [`DatasetBuilder.info`]: Documents the dataset, including feature
names, types, shapes, version, splits, citation, etc.
- [`DatasetBuilder.download_and_prepare`]: Downloads the source... | class_definition | 8,679 | 66,947 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/builder.py | null | 54 |
class GeneratorBasedBuilder(DatasetBuilder):
"""Base class for datasets with data generation based on dict generators.
`GeneratorBasedBuilder` is a convenience class that abstracts away much
of the data writing and reading of `DatasetBuilder`. It expects subclasses to
implement generators of feature di... | class_definition | 66,950 | 79,073 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/builder.py | null | 55 |
class ArrowBasedBuilder(DatasetBuilder):
"""Base class for datasets with data generation based on Arrow loading functions (CSV/JSON/Parquet)."""
@abc.abstractmethod
def _generate_tables(self, **kwargs):
"""Default function generating examples for each `SplitGenerator`.
This function prepro... | class_definition | 79,076 | 90,420 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/builder.py | null | 56 |
class SplitsNotFoundError(ValueError):
pass | class_definition | 1,151 | 1,198 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/inspect.py | null | 57 |
class MissingIndex(Exception):
pass | class_definition | 721 | 760 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/search.py | null | 58 |
class SearchResults(NamedTuple):
scores: List[float]
indices: List[int] | class_definition | 763 | 842 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/search.py | null | 59 |
class BatchedSearchResults(NamedTuple):
total_scores: List[List[float]]
total_indices: List[List[int]] | class_definition | 845 | 955 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/search.py | null | 60 |
class NearestExamplesResults(NamedTuple):
scores: List[float]
examples: dict | class_definition | 958 | 1,042 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/search.py | null | 61 |
class BatchedNearestExamplesResults(NamedTuple):
total_scores: List[List[float]]
total_examples: List[dict] | class_definition | 1,045 | 1,160 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/search.py | null | 62 |
class BaseIndex:
"""Base class for indexing"""
def search(self, query, k: int = 10, **kwargs) -> SearchResults:
"""
To implement.
This method has to return the scores and the indices of the retrieved examples given a certain query.
"""
raise NotImplementedError
def ... | class_definition | 1,163 | 2,655 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/search.py | null | 63 |
class ElasticSearchIndex(BaseIndex):
"""
Sparse index using Elasticsearch. It is used to index text and run queries based on BM25 similarity.
An Elasticsearch server needs to be accessible, and a python client is declared with
```
es_client = Elasticsearch([{'host': 'localhost', 'port': '9200'}])
... | class_definition | 2,658 | 7,728 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/search.py | null | 64 |
class FaissIndex(BaseIndex):
"""
Dense index using Faiss. It is used to index vectors.
Faiss is a library for efficient similarity search and clustering of dense vectors.
It contains algorithms that search in sets of vectors of any size, up to ones that possibly do not fit in RAM.
You can find more ... | class_definition | 7,731 | 17,154 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/search.py | null | 65 |
class IndexableMixin:
"""Add indexing features to `datasets.Dataset`"""
def __init__(self):
self._indexes: Dict[str, BaseIndex] = {}
def __len__(self):
raise NotImplementedError
def __getitem__(self, key):
raise NotImplementedError
def is_index_initialized(self, index_nam... | class_definition | 17,157 | 35,607 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/search.py | null | 66 |
class DatasetsError(Exception):
"""Base class for exceptions in this library.""" | class_definition | 308 | 392 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/exceptions.py | null | 67 |
class DefunctDatasetError(DatasetsError):
"""The dataset has been defunct.""" | class_definition | 395 | 476 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/exceptions.py | null | 68 |
class FileNotFoundDatasetsError(DatasetsError, FileNotFoundError):
"""FileNotFoundError raised by this library.""" | class_definition | 479 | 597 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/exceptions.py | null | 69 |
class DataFilesNotFoundError(FileNotFoundDatasetsError):
"""No (supported) data files found.""" | class_definition | 600 | 699 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/exceptions.py | null | 70 |
class DatasetNotFoundError(FileNotFoundDatasetsError):
"""Dataset not found.
Raised when trying to access:
- a missing dataset, or
- a private/gated dataset and the user is not authenticated.
""" | class_definition | 702 | 918 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/exceptions.py | null | 71 |
class DatasetBuildError(DatasetsError):
pass | class_definition | 921 | 969 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/exceptions.py | null | 72 |
class ManualDownloadError(DatasetBuildError):
pass | class_definition | 972 | 1,026 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/exceptions.py | null | 73 |
class FileFormatError(DatasetBuildError):
pass | class_definition | 1,029 | 1,079 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/exceptions.py | null | 74 |
class DatasetGenerationError(DatasetBuildError):
pass | class_definition | 1,082 | 1,139 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/exceptions.py | null | 75 |
class DatasetGenerationCastError(DatasetGenerationError):
@classmethod
def from_cast_error(
cls,
cast_error: CastError,
builder_name: str,
gen_kwargs: Dict[str, Any],
token: Optional[Union[bool, str]],
) -> "DatasetGenerationCastError":
explanation_message = (... | class_definition | 1,142 | 3,233 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/exceptions.py | null | 76 |
class ChecksumVerificationError(DatasetsError):
"""Error raised during checksums verifications of downloaded files.""" | class_definition | 3,236 | 3,358 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/exceptions.py | null | 77 |
class UnexpectedDownloadedFileError(ChecksumVerificationError):
"""Some downloaded files were not expected.""" | class_definition | 3,361 | 3,475 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/exceptions.py | null | 78 |
class ExpectedMoreDownloadedFilesError(ChecksumVerificationError):
"""Some files were supposed to be downloaded but were not.""" | class_definition | 3,478 | 3,610 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/exceptions.py | null | 79 |
class NonMatchingChecksumError(ChecksumVerificationError):
"""The downloaded file checksum don't match the expected checksum.""" | class_definition | 3,613 | 3,745 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/exceptions.py | null | 80 |
class SplitsVerificationError(DatasetsError):
"""Error raised during splits verifications.""" | class_definition | 3,748 | 3,845 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/exceptions.py | null | 81 |
class UnexpectedSplitsError(SplitsVerificationError):
"""The expected splits of the downloaded file is missing.""" | class_definition | 3,848 | 3,966 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/exceptions.py | null | 82 |
class ExpectedMoreSplitsError(SplitsVerificationError):
"""Some recorded splits are missing.""" | class_definition | 3,969 | 4,068 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/exceptions.py | null | 83 |
class NonMatchingSplitsSizesError(SplitsVerificationError):
"""The splits sizes don't match the expected splits sizes.""" | class_definition | 4,071 | 4,196 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/exceptions.py | null | 84 |
class SplitInfo:
name: str = dataclasses.field(default="", metadata={"include_in_asdict_even_if_is_default": True})
num_bytes: int = dataclasses.field(default=0, metadata={"include_in_asdict_even_if_is_default": True})
num_examples: int = dataclasses.field(default=0, metadata={"include_in_asdict_even_if_is_... | class_definition | 994 | 2,153 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/splits.py | null | 85 |
class SubSplitInfo:
"""Wrapper around a sub split info.
This class expose info on the subsplit:
```
ds, info = datasets.load_dataset(..., split='train[75%:]', with_info=True)
info.splits['train[75%:]'].num_examples
```
"""
instructions: FileInstructions
@property
def num_exampl... | class_definition | 2,167 | 2,764 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/splits.py | null | 86 |
class SplitBase(metaclass=abc.ABCMeta):
# pylint: disable=line-too-long
"""Abstract base class for Split compositionality.
See the
[guide on splits](../loading#slice-splits)
for more information.
There are three parts to the composition:
1) The splits are composed (defined, merged, spl... | class_definition | 2,767 | 9,595 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/splits.py | null | 87 |
class PercentSliceMeta(type):
def __getitem__(cls, slice_value):
if not isinstance(slice_value, slice):
raise ValueError(f"datasets.percent should only be called with slice, not {slice_value}")
return slice_value | class_definition | 9,819 | 10,063 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/splits.py | null | 88 |
class PercentSlice(metaclass=PercentSliceMeta):
# pylint: disable=line-too-long
"""Syntactic sugar for defining slice subsplits: `datasets.percent[75:-5]`.
See the
[guide on splits](../loading#slice-splits)
for more information.
"""
# pylint: enable=line-too-long
pass | class_definition | 10,066 | 10,368 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/splits.py | null | 89 |
class _SplitMerged(SplitBase):
"""Represent two split descriptors merged together."""
def __init__(self, split1, split2):
self._split1 = split1
self._split2 = split2
def get_read_instruction(self, split_dict):
read_instruction1 = self._split1.get_read_instruction(split_dict)
... | class_definition | 10,428 | 10,957 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/splits.py | null | 90 |
class _SubSplit(SplitBase):
"""Represent a sub split of a split descriptor."""
def __init__(self, split, slice_value):
self._split = split
self._slice_value = slice_value
def get_read_instruction(self, split_dict):
return self._split.get_read_instruction(split_dict)[self._slice_val... | class_definition | 10,960 | 11,754 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/splits.py | null | 91 |
class NamedSplit(SplitBase):
"""Descriptor corresponding to a named split (train, test, ...).
Example:
Each descriptor can be composed with other using addition or slice:
```py
split = datasets.Split.TRAIN.subsplit(datasets.percent[0:25]) + datasets.Split.TEST
```
... | class_definition | 11,757 | 14,482 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/splits.py | null | 92 |
class NamedSplitAll(NamedSplit):
"""Split corresponding to the union of all defined dataset splits."""
def __init__(self):
super().__init__("all")
def __repr__(self):
return "NamedSplitAll()"
def get_read_instruction(self, split_dict):
# Merge all dataset split together
... | class_definition | 14,485 | 14,943 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/splits.py | null | 93 |
class Split:
# pylint: disable=line-too-long
"""`Enum` for dataset splits.
Datasets are typically split into different subsets to be used at various
stages of training and evaluation.
- `TRAIN`: the training data.
- `VALIDATION`: the validation data. If present, this is typically used as
... | class_definition | 14,946 | 16,656 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/splits.py | null | 94 |
class SplitReadInstruction:
"""Object containing the reading instruction for the dataset.
Similarly to `SplitDescriptor` nodes, this object can be composed with itself,
but the resolution happens instantaneously, instead of keeping track of the
tree, such as all instructions are compiled and flattened ... | class_definition | 16,861 | 19,218 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/splits.py | null | 95 |
class SplitDict(dict):
"""Split info object."""
def __init__(self, *args, dataset_name=None, **kwargs):
super().__init__(*args, **kwargs)
self.dataset_name = dataset_name
def __getitem__(self, key: Union[SplitBase, str]):
# 1st case: The key exists: `info.splits['train']`
i... | class_definition | 19,221 | 22,283 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/splits.py | null | 96 |
class SplitGenerator:
"""Defines the split information for the generator.
This should be used as returned value of
`GeneratorBasedBuilder._split_generators`.
See `GeneratorBasedBuilder._split_generators` for more info and example
of usage.
Args:
name (`str`):
Name of the `S... | class_definition | 22,297 | 23,441 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/splits.py | null | 97 |
class IndexedTableMixin:
def __init__(self, table: pa.Table):
self._schema: pa.Schema = table.schema
self._batches: List[pa.RecordBatch] = [
recordbatch for recordbatch in table.to_batches() if len(recordbatch) > 0
]
self._offsets: np.ndarray = np.cumsum([0] + [len(b) for... | class_definition | 3,075 | 5,469 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/table.py | null | 98 |
class Table(IndexedTableMixin):
"""
Wraps a pyarrow Table by using composition.
This is the base class for `InMemoryTable`, `MemoryMappedTable` and `ConcatenationTable`.
It implements all the basic attributes/methods of the pyarrow Table class except
the Table transforms: `slice, filter, flatten, c... | class_definition | 5,472 | 21,458 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/table.py | null | 99 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.