cbp.utils

cbp.utils.event_utils

cbp.utils.event_utils.compare_marginals(mar_1, mar_2)[source]
cbp.utils.event_utils.diff_max_marginals(mar_1, mar_2)[source]
cbp.utils.event_utils.engine_loop(engine_fun, max_iter=5000000, tolerance=0.01, error_fun=None, meassure_fun=None, isoutput=False, silent=False)[source]

work engine for loop

Parameters
  • engine_fun – work function

  • max_iter (int, optional) – max iteration, defaults to 5000000

  • tolerance (float, optional) – less than tolerance, stop, defaults to 1e-2

  • error_fun (func, optional) – output the metrics for this iteration, defaults to None

  • meassure_fun (func, optional) – relative distance between continuous two metrics, defaults to None

  • isoutput (bool, optional) – output the distance, defaults to False

  • silent (bool, optional) – output details, defaults to False

Returns

list of relative distance, num of running iteration, timers

cbp.utils.message

class cbp.utils.message.Message(sender, val)[source]

Bases: cbp.utils.message.Message

cbp.utils.np_utils

cbp.utils.np_utils.batch_normal_angle(angle)[source]
cbp.utils.np_utils.empirical_marginal(traj, num_bins)[source]
cbp.utils.np_utils.nd_expand(inputdata, target_shape, expand_dim)[source]

expand ndarray to target shape

Parameters
  • inputdata (list or 1d ndarray) –

  • target_shape (tuple) –

  • expand_dim (int) – [description]

Returns

expanded ndarray with target_shape

Return type

ndarray

>>> inputdata = [1,2]
>>> target_shape = (1,2,3)
>>> expand_dim = 1
>>> output = np.array([
            [1,1,1],
            [2,2,2]
        ])
cbp.utils.np_utils.nd_multiexpand(input_data, target_shape, which_dims)[source]
cbp.utils.np_utils.reduction_ndarray(ndarray, reduction_index)[source]

reduct ndarray according to one index

Parameters
  • ndarray (ndarray) – [description]

  • reduction_index (int) – [description]

Returns

[description]

Return type

ndarray