distancematrix.generator.abstract_generator

Module Contents

Classes

AbstractGenerator

Helper class that provides a standard way to create an ABC using

AbstractBoundGenerator

Helper class that provides a standard way to create an ABC using

AbstractBoundStreamingGenerator

Helper class that provides a standard way to create an ABC using

class distancematrix.generator.abstract_generator.AbstractGenerator

Bases: abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

abstract prepare(self, m, series, query=None)

Create a bound non-streaming generator for the given series and query sequences.

Parameters
  • m – the size of the subsequences used to calculate distances between series and query

  • series – 1D array, used as the horizontal axis of a distance matrix

  • query – 1D array, used as the vertical axis of a distance matrix, or None to indicate a self-join

Returns

a bound generator

abstract prepare_streaming(self, m, series_window, query_window=None)

Create a bound generator that supports streaming data. The generator will need to receive data before any distances can be calculated.

Parameters
  • m – the size of the subsequences used to calculate distances between series and query

  • series_window – number of values to keep in memory for series, the length of the horizontal axis of the distance matrix will be equal to (series_window - m + 1)

  • query_window – number of values to keep in memory for query, the length of the vertical axis of the distance matrix will be equal to (query_window - m + 1), or None to indicate a self-join.

Returns

a bound generator that supports streaming

class distancematrix.generator.abstract_generator.AbstractBoundGenerator

Bases: abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

abstract calc_diagonal(self, diag)

Calculates all distances of the distance matrix diagonal with the given index for the available data.

If diag is zero, this calculates the main diagonal, running from the top left to the bottom right. Any positive value represents a diagonal above the main diagonal, and a negative value represents a diagonal below the main diagonal.

Parameters

diag – the diagonal index

Returns

1D array, containing all values

abstract calc_column(self, column)

Calculates all distances of the distance matrix on the specified column for the available data.

Parameters

column – the column index (starting at 0)

Returns

1D array, containing all values

class distancematrix.generator.abstract_generator.AbstractBoundStreamingGenerator

Bases: abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

abstract append_series(self, values)

Adds more data points to the series sequence (and the query in case of a self-join). Older data points will be dropped if the series would become larger than the foreseen capacity.

Parameters

values – 1D array, the new values to append to the series

Returns

None

abstract append_query(self, values)

Adds more data points to the query sequence. Older data points will be dropped if the query would become larger than the foreseen capacity.

Parameters

values – 1D array, the new values to append to the query

Returns

None