survive.utils.check_data_1d

survive.utils.check_data_1d(data, *, numeric=True, n_exact=None, n_min=None, n_max=None, keep_pandas=True, copy=False, dtype=None, order=None)[source]

Preprocess and validate a one-dimensional array.

Parameters:
data : array-like

The data array. If data is a scalar, it is interpreted as an array of shape (1,).

numeric : bool, optional

If True, ensure that the entries in data are of a numeric type.

n_exact : int, optional

Exact number of entries expected.

n_min : int, optional

Minimum number of entries expected.

n_max : int, optional

Maximum number of entries expected.

keep_pandas : bool, optional

If True, keep a pandas.Series as a Series instead of converting it to a numpy.ndarray.

copy : bool, optional

If True, the array will be copied. If False, the array might be copied depending on the behavior of numpy.array().

dtype : str or type, optional (default: None)

The desired data type of the validated array.

order : str, optional (default: None)

The desired memory layout of the array. See the numpy.array() documentation for details.

Returns:
data : one-dimensional numpy.ndarray or pandas.Series

The validated one-dimensional array.

Raises:
ValueError

If the input array is empty or has more than one dimension, or if any of the optional constraints on the data type or number of entries is violated.