mlrl.common.arrays module¶
Author: Michael Rapp (michael.rapp.ml@gmail.com)
Provides utility functions for handling arrays.
- mlrl.common.arrays.enforce_2d(array: ndarray) ndarray ¶
Converts a given np.ndarray into a two-dimensional array if it is one-dimensional.
- Parameters:
array – A np.ndarray to be converted
- Returns:
A np.ndarray with at least two dimensions
- mlrl.common.arrays.enforce_dense(array, order: str, dtype) ndarray ¶
Converts a given array into a np.ndarray, if necessary, and enforces a specific memory layout and data type to be used.
- Parameters:
array – A np.ndarray or scipy.sparse.matrix to be converted
order – The memory layout to be used. Must be C or F
dtype – The data type to be used
- Returns:
A np.ndarray that uses the given memory layout and data type