Skip to main content
Version: 0.7

utils

superduper.misc.utils

Source code

hash_item​

hash_item(item: Any) -> str
ParameterDescription
itemThe item to hash.

Hash an item.

format_prompt​

format_prompt(X: str,
prompt: str,
context: Optional[List[str]] = None) -> str
ParameterDescription
XThe input to format the prompt with.
promptThe prompt to format.
contextThe context to format the prompt with.

Format a prompt with the given input and context.

grab_source_code_ipython​

grab_source_code_ipython(cls_or_fn: Union[Type,
Callable]) -> str
ParameterDescription
cls_or_fnThe class or function

Grab the source code of a class or function.

merge_dicts​

merge_dicts(r: Dict,
s: Dict) -> dict
ParameterDescription
rThe first dictionary.
sThe second dictionary.

Merge two dictionaries recursively.

r = {'foo': {'bar': 1, 'baz': 2}, 'qux': 3}
s = {'foo': {'bar': 4, 'quux': 5}, 'quux': 6}
merge_dicts(r, s)
# {'foo': {'bar': 4, 'baz': 2, 'quux': 5}, 'qux': 3, 'quux': 6}

str_shape​

str_shape(shape: Union[Sequence[int],
int]) -> str
ParameterDescription
shapeThe shape to convert.

Convert a shape to a string.