patterns module¶
Generic Numba-compiled functions for working with patterns.
discrete_interp_nb function¶
Get the value at a specific position in a target size using discrete interpolation.
fit_pattern_nb function¶
fit_pattern_nb(
arr,
pattern,
interp_mode=3,
rescale_mode=0,
vmin=nan,
vmax=nan,
pmin=nan,
pmax=nan,
invert=False,
error_type=0,
max_error=nan,
max_error_interp_mode=None
)
Fit pattern.
Returns the resized and rescaled pattern and max error.
interp_nb function¶
Get the value at a specific position in a target size using an interpolation mode.
See InterpMode.
interp_resize_1d_nb function¶
Resize an array using interp_nb().
linear_interp_nb function¶
Get the value at a specific position in a target size using linear interpolation.
mixed_interp_nb function¶
Get the value at a specific position in a target size using mixed interpolation.
Mixed interpolation is based on the discrete interpolation, while filling resulting NaN values using the linear interpolation. This way, the vertical scale of the pattern array is respected.
nearest_interp_nb function¶
Get the value at a specific position in a target size using nearest-neighbor interpolation.
pattern_similarity_nb function¶
pattern_similarity_nb(
arr,
pattern,
interp_mode=3,
rescale_mode=0,
vmin=nan,
vmax=nan,
pmin=nan,
pmax=nan,
invert=False,
error_type=0,
distance_measure=0,
max_error=nan,
max_error_interp_mode=None,
max_error_as_maxdist=False,
max_error_strict=False,
min_pct_change=nan,
max_pct_change=nan,
min_similarity=nan,
minp=None
)
Get the similarity between an array and a pattern array.
At each position in the array, the value in arr is first mapped into the range of pattern. Then, the absolute distance between the actual and expected value is calculated (= error). This error is then divided by the maximum error at this position to get a relative value between 0 and 1. Finally, all relative errors are added together and subtracted from 1 to get the similarity measure.