utils module

gensei.utils.evaluate(val, shape=None)

Evaluate a single value or a sequence of values.

The values can be have a uniform (keyword ‘random’) or normal (keyword ‘normal’) random distribution.

Parameters:

val : config value

The value to be evaluated. It can be one of:

  • list: evaluate() is called recursively for each item

  • tuple:
    • (‘random’, [min. values], [max. values]) (uniform)
    • (‘random’, min. value, max. value)
    • (‘normal’, mean, standard deviation)
    • (‘random direction’, dim) : uniform distribution of unit vectors in dimension dim
  • ‘random’ : random value(s) in [0, 1)

  • ‘random direction’ : uniform distribution of unit vectors

    in dimension 3

  • other values are returned as they are.

shape : tuple, optional

Shape of the data when val is ‘random’.

Returns:

out : data

The evaluated data.

gensei.utils.format_dict(d, raw=None, indent=2)

Format a dictionary for printing.

Parameters:

d : dict
The dictionary.
raw : dict
The raw (unadjusted) dictionary to compare with.
indent : int
The indentation level.

Return:

msg : string
The string with dictionary’s key : val formatted in two columns.
gensei.utils.get_random(ranges0, ranges1)

Get an array of random numbers a with the uniform distribution so that ranges0[i] <= a[i] < ranges1[i].

Returns:

a : array

The array of random numbers.

gensei.utils.get_random_direction(dim)
Get a uniform random direction in unit ball of dimension dim.
gensei.utils.get_suffix(n)

Get suffix format string given a number of files.

Examples:

n = 5 -> ‘%01d’ n = 15 -> ‘%02d’ n = 1005 -> ‘%04d’

This Page