numba_choice_bool_axis0

pyoptex.utils.numba.numba_choice_bool_axis0(valids)[source]

For each row in valids, chooses a random index of the true elements in that row. For example, if valids is [[True, False], [True, True]], the first element of out must be 0 as there is no other options, the second element has a 50% chance to be zero, and a 50% chance to be one. If all elements are False, -1 is returned.

Parameters

validsnp.array(2d)

A 2d-boolean matrix.

Returns

outnp.array(1d)

An integer array with the randomly chosen indices.