MODULE REFERENCE
window
anomx.data.processing.dtw.windowDTW Windows
CRWindow
CRWindow(n: int, m: int, ranges: np.ndarray | None = None)Bases: Window
Compressed row representation window. Stores the range of active grid cells in each column. Any window with contiguous columns can be expressed as a CRWindow. Supports efficient iterative construction and updates.
| Parameter | Type | Default |
|---|---|---|
n | int | required |
m | int | required |
ranges | np.ndarray | None | None |
Parameters
- n
The width of the window, must be equal to the length of series1
- m
The height of the window, must be equal to the length of series2
- ranges
The ranges of active cells within a column [[start_column0, end_column0], ...] with shape (n, 2) and where start >= 0 and end <= m.
Members
lengthattribute
length: intcolumn_rangesattribute
column_ranges: array.arrayadd_rangemethod
add_range(column: int, start: int, end: int)Extends the active cells in the column by the range (start,end). Ranges smaller than the current one are ignored. Note (1, m+1), not (0,m) corresponds to an entire column.
Parameters
- column
Column int index
- start
Row element int index where start >= 1 and start <= end
- end
Row element int index where end >= 1 and end <= m+1
| Parameter | Type | Default |
|---|---|---|
column | int | required |
start | int | required |
end | int | required |
addmethod
add(elem: tuple[int, int])Marks a grid cell as active.
Parameters
- elem
Tuple of grid cell index (column, row)
| Parameter | Type | Default |
|---|---|---|
elem | tuple[int, int] | required |
column_lengthmethod
column_length(column: int) -> int| Parameter | Type | Default |
|---|---|---|
column | int | required |
Returns int
column_indexmethod
column_index(elem: tuple[int, int]) -> int| Parameter | Type | Default |
|---|---|---|
elem | tuple[int, int] | required |
Returns int
column_lengthsmethod
Inherited members
Itakura
Itakura(max_slope: float)Bases: CRWindow
Forms the Itakura parallelogram, where max_slope determines the slope of the steeper side.
Examples
>>> x
>>> xxxx
>>> B xxxxxx
>>> xxxxxxxxxxx
>>> xxxxxxxxxxxxxx
>>> xxxxxxxxxxxxxxxxx
>>> xxxxxxxxxxxxxxxxxxxx C
>>> xxxxxxxxxxxxxxxxxxxxx
>>> xxxxxxxxxxxxxxxxxxxxx
>>> xxxxxxxxxxxxxxxxxxxxx
>>> A xxxxxxxxxxxxxxxxxxxxx
>>> xxxxxxxxxxxxxxxxxxxxx
>>> xxxxxxxxxxxxxxxxxxxxx
>>> xxxxxxxxxxxxxxxxxxxx
>>> xxxxxxxxxxxxxxxx D
>>> xxxxxxxxxxxx
>>> xxxxxxxxx
>>> xxxxxx
>>> xxx
>>> x| Parameter | Type | Default |
|---|---|---|
max_slope | float | required |
Parameters
- max_slope
The slope of the steeper parallelogram side.
Members
init_sizemethod
init_size(n: int, m: int)| Parameter | Type | Default |
|---|---|---|
n | int | required |
m | int | required |
NoWindow
NoWindowBases: Window
Window covers the entire grid, meaning every possible alignment between series1 and series2 is considered.
Members
column_indexmethod
column_index(elem: tuple[int, int])| Parameter | Type | Default |
|---|---|---|
elem | tuple[int, int] | required |
column_lengthmethod
column_length(column: int) -> int| Parameter | Type | Default |
|---|---|---|
column | int | required |
Returns int
column_lengthsmethod
Inherited members
SakoeChiba
SakoeChiba(window_size: int)Bases: CRWindow
Forms a diagonal window where window_size controls the maximum allowed shift between the two series. If both time-series have the same time axis, window_size corresponds to the maximum number of time periods
| Parameter | Type | Default |
|---|---|---|
window_size | int | required |
Parameters
- window_size
The maximum allowed shift between the two series used in DTW.
Members
init_sizemethod
init_size(n: int, m: int)| Parameter | Type | Default |
|---|---|---|
n | int | required |
m | int | required |
Window
WindowBases: ABC
Members
nattribute
n: intmattribute
m: intinit_sizemethod
init_size(n: int, m: int)Called by dtw to initialize the window to a certain size.
Parameters
- n
The width of the window, must be equal to the length of
series1used for DTW- m
The height of the window, must be equal to the length of
series2used for DTW
| Parameter | Type | Default |
|---|---|---|
n | int | required |
m | int | required |
column_indexmethod
column_index(elem: tuple[int, int]) -> intGives the number of active grid cells before row element j, in column i.
Parameters
- elem
(i,j) index, where i indexes columns and j rows
Returns
- int
The number of active grid cells before row element j, in column i, If (i,j) is not an active grid cell returns -1
| Parameter | Type | Default |
|---|---|---|
elem | tuple[int, int] | required |
Returns int
column_lengthmethod
column_length(column: int) -> intGives the number of active grid cells in a column.
Parameters
- column
A column in the window, must be within 0 < column < n+1
Returns
- int
The number of active grid cells in a column.
| Parameter | Type | Default |
|---|---|---|
column | int | required |
Returns int
column_lengthsmethod
column_lengths() -> np.ndarrayGives the number of activate grid cells in each column.
Returns
- np.ndarray of shape (n+1,)
The number of active grid cells in each column.
Returns np.ndarray
gtz
gtz(value)| Parameter | Type | Default |
|---|---|---|
value | — | required |