Skip to content

Commit

Permalink
Pairwise distance matrix test
Browse files Browse the repository at this point in the history
  • Loading branch information
kavya-r30 committed Mar 5, 2025
1 parent 3106722 commit 0913d6a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions aeon/visualisation/distances/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Testing for distances specific plotting."""
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""Test pairwise distance matrix plotting."""

import numpy as np
import pytest

from aeon.utils.validation._dependencies import _check_soft_dependencies
from aeon.visualisation import plot_pairwise_distance_matrix


@pytest.mark.skipif(
not _check_soft_dependencies(["matplotlib", "seaborn"], severity="none"),
reason="skip test if required soft dependency not available",
)
def test_plot_pairwise_distance_matrix():
"""Test whether plot_pairwise_distance_matrix runs without error."""
import matplotlib
import matplotlib.pyplot as plt

matplotlib.use("Agg")

distance_matrix = np.array([[0.0, 1.0], [1.0, 0.0]])
a = np.array([1.0, 2.0])
b = np.array([1.5, 2.5])
path = [(0, 0), (1, 1)]

ax = plot_pairwise_distance_matrix(distance_matrix, a, b, path)
fig = plt.gcf()
plt.gcf().canvas.draw_idle()

assert isinstance(fig, plt.Figure)
assert isinstance(ax, plt.Axes)
assert len(fig.axes) > 0

plt.close()

0 comments on commit 0913d6a

Please sign in to comment.