Utils module

This module contains all kinds of utility methods, and can be imported as follows:

>>> from dtaianomaly import utils
dtaianomaly.utils.is_valid_list(value, target_type) bool[source]

Check if the given list is a valid, with each instance being a member of the given type.

Parameters:
  • value (object) – The value to check if it is a valid list

  • target_type (Type) – The type of each object in the given list

Returns:

is_valid – True if and only if the given value is a list and all elements in the list are of type Type, otherwise False.

Return type:

bool

dtaianomaly.utils.is_valid_array_like(array) bool[source]

Check if input is “array-like”. Within dtaianomaly, this is either a numpy array of numerical values or a python sequence of numerical values.

Parameters:

array (object) – The array to check if it is a valid array-like

Returns:

is_valid – True if and only if the given array is either a numpy array or a python sequence, in which the type entirely consists of numerical values, otherwise False.

Return type:

bool

dtaianomaly.utils.is_univariate(X: ndarray) bool[source]

Checks if the given array equals a univariate time series.

Parameters:

X (array-like of shape (n_samples, n_attributes)) – The time series data to check if it is univariate.

Returns:

is_univariate – True if and only if the given time series has only one dimension, or if the second dimension of the time series is of size 1.

Return type:

bool

dtaianomaly.utils.get_dimension(X: ndarray) int[source]

Get the dimension of the given array.

Parameters:

X (array-like of shape (n_samples, n_attributes)) – The time series data to get the dimension from

Returns:

n_attributes – The number of attributes in the given time series.

Return type:

int

class dtaianomaly.utils.PrettyPrintable[source]