int2bool

pyoptex.utils.comp.int2bool(arr, size)[source]

Converts an ndarray of integers to a boolean representation. The input array has size (…, N), the output array has size (…, size), where ‘…’ represent the same shape.

For examples:

  • An array [0, 1] and size 3 will be converted to [True, True, False].

  • An array [[0, 1], [2, 3]] and size 5 will be converted to [[True, True, False, False, False], [False, False, True, True, False]].

Note

Every element in arr must be strictly smaller than size.

Parameters

arrnp.array(nd)

Any nd-array with integers smaller than size.

sizeint

The size of the last dimension in the output array. All elements in arr must be strictly smaller than this number.

Returns

outnp.array(nd)

An nd-array with booleans. The last dimension is equal to size, the other dimensions are all but the last dimension of arr