hyperparameter_hunter.keys package

Submodules

hyperparameter_hunter.keys.hashing module

hyperparameter_hunter.keys.hashing.make_hash_sha256(obj, **kwargs)

Create an sha256 hash of the input obj

Parameters
obj: Object

Object for which a hash will be created

**kwargs: Dict

Extra kwargs to supply to key_handler.hash_callable()

Returns
Stringified sha256 hash
hyperparameter_hunter.keys.hashing.to_hashable(obj, **kwargs)

Format the input obj to be hashable

Parameters
obj: Object

Object to convert to a hashable format

**kwargs: Dict

Extra kwargs to supply to key_handler.hash_callable()

Returns
obj: object

Hashable object

hyperparameter_hunter.keys.hashing.hash_callable(obj, ignore_line_comments=True, ignore_first_line=False, ignore_module=False, ignore_name=False, ignore_keywords=False, ignore_source_lines=False)

Prepare callable object for hashing by selecting important characterization properties

Parameters
obj: Callable

Callable to convert to a hashable format. Supports: function, class, functools.partial

ignore_line_comments: Boolean, default=True

If True, any line comments will be stripped from the source code of obj, specifically any lines that start with zero or more whitespaces, followed by an octothorpe (#). This does not apply to comments on the same line as code

ignore_first_line: Boolean, default=False

If True, strip the first line from the callable’s source code, specifically its name and signature. If ignore_name=True, this will be treated as True

ignore_module: Boolean, default=False

If True, ignore the name of the module containing the source code (obj.__module__)

ignore_name: Boolean, default=False

If True, ignore obj.__name__. Note the difference from ignore_first_line, which strips the entire callable signature from the source code. ignore_name does not alter the source code. To ensure thorough ignorance, ignore_first_line=True is recommended

ignore_keywords: Boolean, default=False

If True and obj is a functools.partial, ignore obj.keywords

ignore_source_lines: Boolean, default=False

If True, all source code will be ignored by the hashing function. Ignoring all other kwargs, this means that only obj.__module__, and obj.__name__, (and obj.keywords if obj is partial) will be used for hashing

Returns
Tuple

Hashable properties of the callable object input

hyperparameter_hunter.keys.hashing.is_line_comment(string)

Return True if the given string is a line comment, else False

Parameters
string: Str

The str in which to check for a line comment

Returns
Boolean

hyperparameter_hunter.keys.makers module

This module handles the creation of cross_experiment_key s and hyperparameter_key s for hyperparameter_hunter.environment.Environment, and hyperparameter_hunter.experiments.BaseExperiment, respectively. It also handles the treatment of complex-typed inputs and their storage in the ‘KeyAttributeLookup’ subdirectory. The descendants of hyperparameter_hunter.keys.makers.KeyMaker defined herein are each responsible for the generation and saving of their keys, as well as determining whether such a key already exists

Module contents