array_util.py¶
Some useful array utilities.
-
openmdao.util.array_util.array_idx_iter(shape)[source]¶ Return an iterator over the indices into a n-dimensional array.
Args: shape : tuple
shape of the array.
-
openmdao.util.array_util.evenly_distrib_idxs(num_divisions, arr_size)[source]¶ Given a number of divisions and the size of an array, chop the array up into pieces according to number of divisions, keeping the distribution of entries as even as possible.
Args: num_divisions : int
Number of parts to divide the array into.
arr_size : int
Number of entries in the array.
Returns: tuple
a tuple of (sizes, offsets), where sizes and offsets contain values for all divisions.
-
openmdao.util.array_util.to_slice(idxs)[source]¶ Convert an index array to a slice if possible. Otherwise, return the index array. Indices are assumed to be sorted in ascending order.