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 tracked_list(list):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.last_item = None
def __iter__(self) -> Iterator:
for x in super().__iter__():
self.last_item = x
yield x
self.last_item = None
def __repr__(... | class_definition | 602 | 1,096 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/track.py | null | 200 |
class TrackedIterableFromGenerator(Iterable):
"""Utility class to create an iterable from a generator function, in order to reset the generator when needed."""
def __init__(self, generator, *args):
super().__init__()
self.generator = generator
self.args = args
self.last_item = N... | class_definition | 1,099 | 1,855 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/track.py | null | 201 |
class NonMutableDict(dict):
"""Dict where keys can only be added but not modified.
Will raise an error if the user try to overwrite one key. The error message
can be customized during construction. It will be formatted using {key} for
the overwritten key.
"""
def __init__(self, *args, **kwargs... | class_definition | 10,782 | 11,735 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/py_utils.py | null | 202 |
class classproperty(property): # pylint: disable=invalid-name
"""Descriptor to be used as decorator for @classmethods."""
def __get__(self, obj, objtype=None):
return self.fget.__get__(None, objtype)() | class_definition | 11,738 | 11,957 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/py_utils.py | null | 203 |
class NestedDataStructure:
def __init__(self, data=None):
self.data = data if data is not None else []
def flatten(self, data=None):
data = data if data is not None else self.data
if isinstance(data, dict):
return self.flatten(list(data.values()))
elif isinstance(dat... | class_definition | 19,811 | 20,273 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/py_utils.py | null | 204 |
class tqdm(old_tqdm):
"""
Class to override `disable` argument in case progress bars are globally disabled.
Taken from https://github.com/tqdm/tqdm/issues/619#issuecomment-619639324.
"""
def __init__(self, *args, **kwargs):
if are_progress_bars_disabled():
kwargs["disable"] = T... | class_definition | 3,488 | 4,110 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/tqdm.py | null | 205 |
class _PatchedModuleObj:
"""Set all the modules components as attributes of the _PatchedModuleObj object."""
def __init__(self, module, attrs=None):
attrs = attrs or []
if module is not None:
for key in module.__dict__:
if key in attrs or not key.startswith("__"):
... | class_definition | 103 | 590 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/patching.py | null | 206 |
class patch_submodule:
"""
Patch a submodule attribute of an object, by keeping all other submodules intact at all levels.
Example::
>>> import importlib
>>> from datasets.load import dataset_module_factory
>>> from datasets.streaming import patch_submodule, xjoin
>>>
... | class_definition | 593 | 4,954 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/patching.py | null | 207 |
class FileLock(FileLock_):
"""
A `filelock.FileLock` initializer that handles long paths.
It also uses the current umask for lock files.
"""
MAX_FILENAME_LENGTH = 255
def __init__(self, lock_file, *args, **kwargs):
# The "mode" argument is required if we want to use the current umask i... | class_definition | 876 | 2,369 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/_filelock.py | null | 208 |
class TqdmCallback(fsspec.callbacks.TqdmCallback):
def __init__(self, tqdm_kwargs=None, *args, **kwargs):
if config.FSSPEC_VERSION < version.parse("2024.2.0"):
super().__init__(tqdm_kwargs, *args, **kwargs)
self._tqdm = _tqdm # replace tqdm module by datasets.utils.tqdm module
... | class_definition | 11,994 | 12,425 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/file_utils.py | null | 209 |
class NonStreamableDatasetError(Exception):
pass | class_definition | 18,763 | 18,815 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/file_utils.py | null | 210 |
class xPath(type(Path())):
"""Extension of `pathlib.Path` to support both local paths and remote URLs."""
def __str__(self):
path_str = super().__str__()
main_hop, *rest_hops = path_str.split("::")
if is_local_path(main_hop):
return main_hop
path_as_posix = path_str.... | class_definition | 40,898 | 45,786 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/file_utils.py | null | 211 |
class ArchiveIterable(TrackedIterableFromGenerator):
"""An iterable of (path, fileobj) from a TAR archive, used by `iter_archive`"""
@staticmethod
def _iter_tar(f):
stream = tarfile.open(fileobj=f, mode="r|*")
for tarinfo in stream:
file_path = tarinfo.name
if not ta... | class_definition | 50,356 | 52,759 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/file_utils.py | null | 212 |
class FilesIterable(TrackedIterableFromGenerator):
"""An iterable of paths from a list of directories or files"""
@classmethod
def _iter_from_urlpaths(
cls, urlpaths: Union[str, List[str]], download_config: Optional[DownloadConfig] = None
) -> Generator[str, None, None]:
if not isinstan... | class_definition | 52,762 | 54,288 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/file_utils.py | null | 213 |
class Pickler(dill.Pickler):
dispatch = dill._dill.MetaCatchingDict(dill.Pickler.dispatch.copy())
_legacy_no_dict_keys_sorting = False
def save(self, obj, save_persistent_id=True):
obj_type = type(obj)
if obj_type not in self.dispatch:
if "regex" in sys.modules:
... | class_definition | 847 | 3,422 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/_dill.py | null | 214 |
class ExtractManager:
def __init__(self, cache_dir: Optional[str] = None):
self.extract_dir = (
os.path.join(cache_dir, config.EXTRACTED_DATASETS_DIR) if cache_dir else config.EXTRACTED_DATASETS_PATH
)
self.extractor = Extractor
def _get_output_path(self, path: str) -> str:
... | class_definition | 354 | 1,662 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/extract.py | null | 215 |
class BaseExtractor(ABC):
@classmethod
@abstractmethod
def is_extractable(cls, path: Union[Path, str], **kwargs) -> bool: ...
@staticmethod
@abstractmethod
def extract(input_path: Union[Path, str], output_path: Union[Path, str]) -> None: ... | class_definition | 1,665 | 1,931 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/extract.py | null | 216 |
class MagicNumberBaseExtractor(BaseExtractor, ABC):
magic_numbers: List[bytes] = []
@staticmethod
def read_magic_number(path: Union[Path, str], magic_number_length: int):
with open(path, "rb") as f:
return f.read(magic_number_length)
@classmethod
def is_extractable(cls, path: U... | class_definition | 1,934 | 2,696 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/extract.py | null | 217 |
class TarExtractor(BaseExtractor):
@classmethod
def is_extractable(cls, path: Union[Path, str], **kwargs) -> bool:
return tarfile.is_tarfile(path)
@staticmethod
def safemembers(members, output_path):
"""
Fix for CVE-2007-4559
Desc:
Directory traversal vulnera... | class_definition | 2,699 | 4,848 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/extract.py | null | 218 |
class GzipExtractor(MagicNumberBaseExtractor):
magic_numbers = [b"\x1f\x8b"]
@staticmethod
def extract(input_path: Union[Path, str], output_path: Union[Path, str]) -> None:
with gzip.open(input_path, "rb") as gzip_file:
with open(output_path, "wb") as extracted_file:
shu... | class_definition | 4,851 | 5,213 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/extract.py | null | 219 |
class ZipExtractor(MagicNumberBaseExtractor):
magic_numbers = [
b"PK\x03\x04",
b"PK\x05\x06", # empty archive
b"PK\x07\x08", # spanned archive
]
@classmethod
def is_extractable(cls, path: Union[Path, str], magic_number: bytes = b"") -> bool:
if super().is_extractable(p... | class_definition | 5,216 | 7,612 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/extract.py | null | 220 |
class XzExtractor(MagicNumberBaseExtractor):
magic_numbers = [b"\xfd\x37\x7a\x58\x5a\x00"]
@staticmethod
def extract(input_path: Union[Path, str], output_path: Union[Path, str]) -> None:
with lzma.open(input_path) as compressed_file:
with open(output_path, "wb") as extracted_file:
... | class_definition | 7,615 | 7,997 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/extract.py | null | 221 |
class RarExtractor(MagicNumberBaseExtractor):
magic_numbers = [b"Rar!\x1a\x07\x00", b"Rar!\x1a\x07\x01\x00"] # RAR_ID # RAR5_ID
@staticmethod
def extract(input_path: Union[Path, str], output_path: Union[Path, str]) -> None:
if not config.RARFILE_AVAILABLE:
raise ImportError("Please pi... | class_definition | 8,000 | 8,506 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/extract.py | null | 222 |
class ZstdExtractor(MagicNumberBaseExtractor):
magic_numbers = [b"\x28\xb5\x2f\xfd"]
@staticmethod
def extract(input_path: Union[Path, str], output_path: Union[Path, str]) -> None:
if not config.ZSTANDARD_AVAILABLE:
raise ImportError("Please pip install zstandard")
import zstand... | class_definition | 8,509 | 8,995 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/extract.py | null | 223 |
class Bzip2Extractor(MagicNumberBaseExtractor):
magic_numbers = [b"\x42\x5a\x68"]
@staticmethod
def extract(input_path: Union[Path, str], output_path: Union[Path, str]) -> None:
with bz2.open(input_path, "rb") as compressed_file:
with open(output_path, "wb") as extracted_file:
... | class_definition | 8,998 | 9,376 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/extract.py | null | 224 |
class SevenZipExtractor(MagicNumberBaseExtractor):
magic_numbers = [b"\x37\x7a\xbc\xaf\x27\x1c"]
@staticmethod
def extract(input_path: Union[Path, str], output_path: Union[Path, str]) -> None:
if not config.PY7ZR_AVAILABLE:
raise ImportError("Please pip install py7zr")
import py... | class_definition | 9,379 | 9,856 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/extract.py | null | 225 |
class Lz4Extractor(MagicNumberBaseExtractor):
magic_numbers = [b"\x04\x22\x4d\x18"]
@staticmethod
def extract(input_path: Union[Path, str], output_path: Union[Path, str]) -> None:
if not config.LZ4_AVAILABLE:
raise ImportError("Please pip install lz4")
import lz4.frame
... | class_definition | 9,859 | 10,364 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/extract.py | null | 226 |
class Extractor:
# Put zip file to the last, b/c it is possible wrongly detected as zip (I guess it means: as tar or gzip)
extractors: Dict[str, Type[BaseExtractor]] = {
"tar": TarExtractor,
"gzip": GzipExtractor,
"zip": ZipExtractor,
"xz": XzExtractor,
"rar": RarExtract... | class_definition | 10,367 | 13,038 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/extract.py | null | 227 |
class SharedMemoryContext:
# This is a context manager for creating shared memory that ensures cleanup happens even if a process is interrupted
# The process that creates shared memory is always the one responsible for unlinking it in the end
def __init__(self):
self.created_shms = []
self.o... | class_definition | 8,870 | 10,071 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/tf_utils.py | null | 228 |
class NumpyMultiprocessingGenerator:
def __init__(
self,
dataset,
cols_to_retain,
collate_fn,
collate_fn_args,
columns_to_np_types,
output_signature,
shuffle,
batch_size,
drop_remainder,
num_workers,
):
self.dataset ... | class_definition | 10,074 | 21,655 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/tf_utils.py | null | 229 |
class VerificationMode(enum.Enum):
"""`Enum` that specifies which verification checks to run.
The default mode is `BASIC_CHECKS`, which will perform only rudimentary checks to avoid slowdowns
when generating/downloading a dataset for the first time.
The verification modes:
| ... | class_definition | 412 | 1,490 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/info_utils.py | null | 230 |
class OnAccess(enum.EnumMeta):
"""
Enum metaclass that calls a user-specified function whenever a member is accessed.
"""
def __getattribute__(cls, name):
obj = super().__getattribute__(name)
if isinstance(obj, enum.Enum) and obj._on_access:
obj._on_access()
return o... | class_definition | 1,958 | 2,743 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/deprecation_utils.py | null | 231 |
class DeprecatedEnum(enum.Enum, metaclass=OnAccess):
"""
Enum class that calls `deprecate` method whenever a member is accessed.
"""
def __new__(cls, value):
member = object.__new__(cls)
member._value_ = value
member._on_access = member.deprecate
return member
@prop... | class_definition | 2,746 | 3,451 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/utils/deprecation_utils.py | null | 232 |
class DownloadConfig:
"""Configuration for our cached path manager.
Attributes:
cache_dir (`str` or `Path`, *optional*):
Specify a cache directory to save the file to (overwrite the
default cache dir).
force_download (`bool`, defaults to `False`):
If `True`, ... | class_definition | 160 | 3,800 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/download/download_config.py | null | 233 |
class DownloadMode(enum.Enum):
"""`Enum` for how to treat pre-existing downloads and data.
The default mode is `REUSE_DATASET_IF_EXISTS`, which will reuse both
raw downloads and the prepared dataset if they exist.
The generations modes:
| | Downloads | Dataset ... | class_definition | 1,430 | 2,175 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/download/download_manager.py | null | 234 |
class DownloadManager:
is_streaming = False
def __init__(
self,
dataset_name: Optional[str] = None,
data_dir: Optional[str] = None,
download_config: Optional[DownloadConfig] = None,
base_path: Optional[str] = None,
record_checksums=True,
):
"""Downloa... | class_definition | 2,178 | 12,773 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/download/download_manager.py | null | 235 |
class StreamingDownloadManager:
"""
Download manager that uses the "::" separator to navigate through (possibly remote) compressed archives.
Contrary to the regular `DownloadManager`, the `download` and `extract` methods don't actually download nor extract
data, but they rather return the path or url th... | class_definition | 891 | 7,522 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/download/streaming_download_manager.py | null | 236 |
class PolarsArrowExtractor(BaseArrowExtractor["pl.DataFrame", "pl.Series", "pl.DataFrame"]):
def extract_row(self, pa_table: pa.Table) -> "pl.DataFrame":
if config.POLARS_AVAILABLE:
if "polars" not in sys.modules:
import polars
else:
polars = sys.modul... | class_definition | 998 | 2,357 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/formatting/polars_formatter.py | null | 237 |
class PolarsFeaturesDecoder:
def __init__(self, features: Optional[Features]):
self.features = features
import polars as pl # noqa: F401 - import pl at initialization
def decode_row(self, row: "pl.DataFrame") -> "pl.DataFrame":
decode = (
{
column_name: no_o... | class_definition | 2,360 | 3,595 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/formatting/polars_formatter.py | null | 238 |
class PolarsFormatter(TensorFormatter[Mapping, "pl.DataFrame", Mapping]):
def __init__(self, features=None, **np_array_kwargs):
super().__init__(features=features)
self.np_array_kwargs = np_array_kwargs
self.polars_arrow_extractor = PolarsArrowExtractor
self.polars_features_decoder =... | class_definition | 3,598 | 4,699 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/formatting/polars_formatter.py | null | 239 |
class BaseArrowExtractor(Generic[RowFormat, ColumnFormat, BatchFormat]):
"""
Arrow extractor are used to extract data from pyarrow tables.
It makes it possible to extract rows, columns and batches.
These three extractions types have to be implemented.
"""
def extract_row(self, pa_table: pa.Tabl... | class_definition | 3,964 | 4,534 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/formatting/formatting.py | null | 240 |
class SimpleArrowExtractor(BaseArrowExtractor[pa.Table, pa.Array, pa.Table]):
def extract_row(self, pa_table: pa.Table) -> pa.Table:
return pa_table
def extract_column(self, pa_table: pa.Table) -> pa.Array:
return pa_table.column(0)
def extract_batch(self, pa_table: pa.Table) -> pa.Table:
... | class_definition | 4,727 | 5,070 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/formatting/formatting.py | null | 241 |
class PythonArrowExtractor(BaseArrowExtractor[dict, list, dict]):
def extract_row(self, pa_table: pa.Table) -> dict:
return _unnest(pa_table.to_pydict())
def extract_column(self, pa_table: pa.Table) -> list:
return pa_table.column(0).to_pylist()
def extract_batch(self, pa_table: pa.Table) ... | class_definition | 5,073 | 5,437 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/formatting/formatting.py | null | 242 |
class NumpyArrowExtractor(BaseArrowExtractor[dict, np.ndarray, dict]):
def __init__(self, **np_array_kwargs):
self.np_array_kwargs = np_array_kwargs
def extract_row(self, pa_table: pa.Table) -> dict:
return _unnest(self.extract_batch(pa_table))
def extract_column(self, pa_table: pa.Table) ... | class_definition | 5,440 | 8,032 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/formatting/formatting.py | null | 243 |
class PandasArrowExtractor(BaseArrowExtractor[pd.DataFrame, pd.Series, pd.DataFrame]):
def extract_row(self, pa_table: pa.Table) -> pd.DataFrame:
return pa_table.slice(length=1).to_pandas(types_mapper=pandas_types_mapper)
def extract_column(self, pa_table: pa.Table) -> pd.Series:
return pa_tabl... | class_definition | 8,035 | 8,572 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/formatting/formatting.py | null | 244 |
class PythonFeaturesDecoder:
def __init__(
self, features: Optional[Features], token_per_repo_id: Optional[Dict[str, Union[str, bool, None]]] = None
):
self.features = features
self.token_per_repo_id = token_per_repo_id
def decode_row(self, row: dict) -> dict:
return self.fe... | class_definition | 8,575 | 9,279 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/formatting/formatting.py | null | 245 |
class PandasFeaturesDecoder:
def __init__(self, features: Optional[Features]):
self.features = features
def decode_row(self, row: pd.DataFrame) -> pd.DataFrame:
decode = (
{
column_name: no_op_if_value_is_null(partial(decode_nested_example, feature))
... | class_definition | 9,282 | 10,431 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/formatting/formatting.py | null | 246 |
class LazyDict(MutableMapping):
"""A dictionary backed by Arrow data. The values are formatted on-the-fly when accessing the dictionary."""
def __init__(self, pa_table: pa.Table, formatter: "Formatter"):
self.pa_table = pa_table
self.formatter = formatter
self.data = {key: None for key... | class_definition | 10,434 | 14,023 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/formatting/formatting.py | null | 247 |
class LazyRow(LazyDict):
def format(self, key):
return self.formatter.format_column(self.pa_table.select([key]))[0] | class_definition | 14,026 | 14,153 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/formatting/formatting.py | null | 248 |
class LazyBatch(LazyDict):
def format(self, key):
return self.formatter.format_column(self.pa_table.select([key])) | class_definition | 14,156 | 14,282 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/formatting/formatting.py | null | 249 |
class Formatter(Generic[RowFormat, ColumnFormat, BatchFormat]):
"""
A formatter is an object that extracts and formats data from pyarrow tables.
It defines the formatting for rows, columns and batches.
"""
simple_arrow_extractor = SimpleArrowExtractor
python_arrow_extractor = PythonArrowExtract... | class_definition | 14,285 | 15,775 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/formatting/formatting.py | null | 250 |
class TensorFormatter(Formatter[RowFormat, ColumnFormat, BatchFormat]):
def recursive_tensorize(self, data_struct: dict):
raise NotImplementedError | class_definition | 15,778 | 15,937 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/formatting/formatting.py | null | 251 |
class ArrowFormatter(Formatter[pa.Table, pa.Array, pa.Table]):
def format_row(self, pa_table: pa.Table) -> pa.Table:
return self.simple_arrow_extractor().extract_row(pa_table)
def format_column(self, pa_table: pa.Table) -> pa.Array:
return self.simple_arrow_extractor().extract_column(pa_table)
... | class_definition | 15,940 | 16,389 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/formatting/formatting.py | null | 252 |
class PythonFormatter(Formatter[Mapping, list, Mapping]):
def __init__(self, features=None, lazy=False, token_per_repo_id=None):
super().__init__(features, token_per_repo_id)
self.lazy = lazy
def format_row(self, pa_table: pa.Table) -> Mapping:
if self.lazy:
return LazyRow(p... | class_definition | 16,392 | 17,399 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/formatting/formatting.py | null | 253 |
class PandasFormatter(Formatter[pd.DataFrame, pd.Series, pd.DataFrame]):
def format_row(self, pa_table: pa.Table) -> pd.DataFrame:
row = self.pandas_arrow_extractor().extract_row(pa_table)
row = self.pandas_features_decoder.decode_row(row)
return row
def format_column(self, pa_table: pa... | class_definition | 17,402 | 18,144 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/formatting/formatting.py | null | 254 |
class CustomFormatter(Formatter[dict, ColumnFormat, dict]):
"""
A user-defined custom formatter function defined by a ``transform``.
The transform must take as input a batch of data extracted for an arrow table using the python extractor,
and return a batch.
If the output batch is not a dict, then o... | class_definition | 18,147 | 20,392 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/formatting/formatting.py | null | 255 |
class TorchFormatter(TensorFormatter[Mapping, "torch.Tensor", Mapping]):
def __init__(self, features=None, token_per_repo_id=None, **torch_tensor_kwargs):
super().__init__(features=features, token_per_repo_id=token_per_repo_id)
self.torch_tensor_kwargs = torch_tensor_kwargs
import torch # n... | class_definition | 871 | 5,067 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/formatting/torch_formatter.py | null | 256 |
class JaxFormatter(TensorFormatter[Mapping, "jax.Array", Mapping]):
def __init__(self, features=None, device=None, token_per_repo_id=None, **jnp_array_kwargs):
super().__init__(features=features, token_per_repo_id=token_per_repo_id)
import jax
from jaxlib.xla_client import Device
if... | class_definition | 1,004 | 7,445 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/formatting/jax_formatter.py | null | 257 |
class TFFormatter(TensorFormatter[Mapping, "tf.Tensor", Mapping]):
def __init__(self, features=None, token_per_repo_id=None, **tf_tensor_kwargs):
super().__init__(features=features, token_per_repo_id=token_per_repo_id)
self.tf_tensor_kwargs = tf_tensor_kwargs
import tensorflow as tf # noqa:... | class_definition | 882 | 5,294 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/formatting/tf_formatter.py | null | 258 |
class NumpyFormatter(TensorFormatter[Mapping, np.ndarray, Mapping]):
def __init__(self, features=None, token_per_repo_id=None, **np_array_kwargs):
super().__init__(features=features, token_per_repo_id=token_per_repo_id)
self.np_array_kwargs = np_array_kwargs
def _consolidate(self, column):
... | class_definition | 782 | 5,107 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/formatting/np_formatter.py | null | 259 |
class DeleteFromHubCommand(BaseDatasetsCLICommand):
@staticmethod
def register_subcommand(parser):
parser: ArgumentParser = parser.add_parser("delete_from_hub", help="Delete dataset config from the Hub")
parser.add_argument(
"dataset_id", help="source dataset ID, e.g. USERNAME/DATASE... | class_definition | 324 | 1,395 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/commands/delete_from_hub.py | null | 260 |
class EnvironmentCommand(BaseDatasetsCLICommand):
@staticmethod
def register_subcommand(parser: ArgumentParser):
download_parser = parser.add_parser("env", help="Print relevant system environment info.")
download_parser.set_defaults(func=info_command_factory)
def run(self):
info = {... | class_definition | 282 | 1,238 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/commands/env.py | null | 261 |
class ConvertToParquetCommand(BaseDatasetsCLICommand):
@staticmethod
def register_subcommand(parser):
parser: ArgumentParser = parser.add_parser("convert_to_parquet", help="Convert dataset to Parquet")
parser.add_argument(
"dataset_id", help="source dataset ID, e.g. USERNAME/DATASET_... | class_definition | 336 | 1,592 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/commands/convert_to_parquet.py | null | 262 |
class ConvertCommand(BaseDatasetsCLICommand):
@staticmethod
def register_subcommand(parser: ArgumentParser):
"""
Register this command to argparse so it's available for the datasets-cli
Args:
parser: Root parser to register command-specific arguments
"""
trai... | class_definition | 1,477 | 7,879 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/commands/convert.py | null | 263 |
class BaseDatasetsCLICommand(ABC):
@staticmethod
@abstractmethod
def register_subcommand(parser: ArgumentParser):
raise NotImplementedError()
@abstractmethod
def run(self):
raise NotImplementedError() | class_definition | 74 | 311 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/commands/__init__.py | null | 264 |
class TestCommand(BaseDatasetsCLICommand):
__test__ = False # to tell pytest it's not a test class
@staticmethod
def register_subcommand(parser: ArgumentParser):
test_parser = parser.add_parser("test", help="Test dataset implementation.")
test_parser.add_argument("--name", type=str, defaul... | class_definition | 921 | 9,087 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/commands/test.py | null | 265 |
class BaseCompressedFileFileSystem(AbstractArchiveFileSystem):
"""Read contents of compressed file as a filesystem with one file inside."""
root_marker = ""
protocol: str = (
None # protocol passed in prefix to the url. ex: "gzip", for gzip://file.txt::http://foo.bar/file.txt.gz
)
compress... | class_definition | 138 | 3,486 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/filesystems/compression.py | null | 266 |
class Bz2FileSystem(BaseCompressedFileFileSystem):
"""Read contents of BZ2 file as a filesystem with one file inside."""
protocol = "bz2"
compression = "bz2"
extension = ".bz2" | class_definition | 3,489 | 3,682 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/filesystems/compression.py | null | 267 |
class GzipFileSystem(BaseCompressedFileFileSystem):
"""Read contents of GZIP file as a filesystem with one file inside."""
protocol = "gzip"
compression = "gzip"
extension = ".gz" | class_definition | 3,685 | 3,881 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/filesystems/compression.py | null | 268 |
class Lz4FileSystem(BaseCompressedFileFileSystem):
"""Read contents of LZ4 file as a filesystem with one file inside."""
protocol = "lz4"
compression = "lz4"
extension = ".lz4" | class_definition | 3,884 | 4,077 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/filesystems/compression.py | null | 269 |
class XzFileSystem(BaseCompressedFileFileSystem):
"""Read contents of .xz (LZMA) file as a filesystem with one file inside."""
protocol = "xz"
compression = "xz"
extension = ".xz" | class_definition | 4,080 | 4,276 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/filesystems/compression.py | null | 270 |
class ZstdFileSystem(BaseCompressedFileFileSystem):
"""
Read contents of .zstd file as a filesystem with one file inside.
"""
protocol = "zstd"
compression = "zstd"
extension = ".zst" | class_definition | 4,279 | 4,487 | 0 | /Users/nielsrogge/Documents/python_projecten/datasets/src/datasets/filesystems/compression.py | null | 271 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.