Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions aeon/distances/_shift_scale_invariant.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ def _univariate_shift_scale_invariant_distance(
shifted_y = y
elif sh < 0:
# Shift left
shifted_y = np.append(y[-sh:], np.zeros(-sh))
shifted_y = np.append(y[-sh:], np.zeros(-sh, dtype=y.dtype))
else:
# Shift right
shifted_y = np.append(np.zeros(sh), y[:-sh])
shifted_y = np.append(np.zeros(sh, dtype=y.dtype), y[:-sh])

dist = _scale_d(x, shifted_y)

Expand Down
15 changes: 15 additions & 0 deletions aeon/distances/tests/test_miscellaneous_distances.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,18 @@ def test_shift_scale_invariant_distance():
assert univariate_shift[1].shape == (10,)
assert isinstance(multivariate_shift[1], np.ndarray)
assert multivariate_shift[1].shape == (3, 10)


def test_shift_scale_invariant_distance_float32():
"""Test that float32 input does not raise a numba TypingError (#3722).

The zero-padding in the shift branches used to default to float64, which could
not unify with the float32 input inside the numba-compiled distance.
"""
x = make_example_2d_numpy_series(n_channels=1, n_timepoints=10, random_state=1)
y = make_example_2d_numpy_series(n_channels=1, n_timepoints=10, random_state=2)

dist64 = shift_scale_invariant_distance(x.astype(np.float64), y.astype(np.float64))
dist32 = shift_scale_invariant_distance(x.astype(np.float32), y.astype(np.float32))

assert_almost_equal(dist32, dist64, decimal=4)
Loading