yann_utils package
Submodules
yann_utils.chunking module
Utilities for chunking objects into bytes and reconstructing them.
- yann_utils.chunking.chunk_obj(obj: Any, chunk_size_mb: int) Iterable[bytes] [source]
Chunk an object into bytes of a given size.
- yann_utils.chunking.get_chunks(dir: str) Iterable[str] [source]
Get the chunks of an object from a directory.
- yann_utils.chunking.get_numeric_suffix(file_name: str) None [source]
Get the numeric suffix of a file name.
yann_utils.phd module
yann_utils.utils module
General utility functions.
- class yann_utils.utils.Cache[source]
Bases:
object
Persistent and automated caching of objects.
- locs: List[str] = []
- os = <module 'os' (frozen)>
- yann_utils.utils.enumerate_flipped(xs: List[E]) Generator[Tuple[E, int], None, None] [source]
>>> list(enumerate_flipped(["a", "b", "c"])) [('a', 0), ('b', 1), ('c', 2)]
- yann_utils.utils.flatten(list_o_list: List[List[T]]) List[T] [source]
>>> flatten([[1, 2], [3, 4]]) [1, 2, 3, 4]
- yann_utils.utils.invert_dict(d: Dict[A, List[B]]) Dict[B, A] [source]
Convert dictionary of lists to flat dictionary with values as keys.
- yann_utils.utils.list_accessor(objects: List[O], field: str) List[A] [source]
>>> list_accessor([{"a": 1}, {"a": 2}], "a") [1, 2]
- yann_utils.utils.multiprocess_apply(func, args, n_jobs: int = 8) List[Any] [source]
Macro for multicore iteration.
Module contents
Top-level package for Yann’s Utilities.