utils module

Auxiliary module with simple utility and informative functions.

utils.dict_to_str(d, indent=0)[source]

Returns a vertically formatted string representation of a dictionary.

utils.list_to_str(l, indent=0)[source]

Returns a vertically formatted string representation of a list.

utils.pickle_objects(fname, some_list)[source]

Pickles a list of objects to a binary file.

utils.unpickle_objects(fname)[source]

Returns an a list of objects from a binary file.

utils.cpu_and_system_props()[source]

Returns a dictionary with properties of CPU and OS.

utils.gpu_props()[source]

Returns a dictionary with properties of GPU device.

utils.hash_function(s)[source]

Returns a hash code (integer) for given string as a base 31 expansion.

utils.hash_str(params, digits)[source]
class utils.Logger(fname)[source]

Bases: object

Class for simultaneous logging to console and a log file (for purposes of experiments).

__init__(fname)[source]

Constructor of MCTSNC instances.

write(message)[source]

Writes a message to console and a log file.

flush()[source]

Empty function required for buffering.

__module__ = 'utils'
utils.experiment_hash_str(matchup_info, c_props, g_props, main_hs_digits=10, matchup_hs_digits=5, env_hs_digits=3)[source]

Returns a hash string for an experiment, based on its settings and properties.

utils.save_and_zip_experiment(experiment_hs, experiment_info, folder)[source]

Saves and zips .json and .log files for an experiment given its hash string and information stored in a dictionary.

utils.unzip_and_load_experiment(experiment_hs, folder)[source]

Unzips, loads an experiment given its hash string, and returns a dictionary with experiments’ information.