paraphernalia.utils module

Miscellaneous utility functions.

divide(whole, part, min_overlap=0)[source]

Divide whole into several part-sized chunks which overlap by at least min_overlap.

Parameters
  • whole (int) – The total to subdivide

  • part (int) – The size of the chunk

  • min_overlap (int, optional) – The minimum overlap between chunks. Defaults to 0 i.e. chunks won’t overlap unless required.

Returns

A list of chunk offset

Return type

List[int]

step_down(steps, iterations)[source]

Step down generator.

Deprecated since version 0.2.0: This will be removed

Note

  • Add value checks

  • Think about how to do this kind of thing more generically

Parameters
  • steps – the number of plateaus

  • iterations – the total number of iterations over which to step down from 1.0 to 0.0

slugify(*bits)[source]

Make a lower-case alphanumeric representation of the arguments by stripping other characters and replacing spaces with hyphens.

Return type

str

ensure_dir_exists(path)[source]
Parameters

path (pathlib.Path) –

Return type

pathlib.Path

download(url, target=None, overwrite=False)[source]

Download url to local disk and return the Path to which it was written.

Parameters
  • url (str) – the URL to fetch.

  • target (Path, optional) – The target path. Defaults to None.

  • overwrite (bool, optional) – If true, overwrite the target path. Defaults to False.

Raises

Exception – if the download target is a directory

Returns

the file that was written

Return type

Path