Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadtourei committed Jan 23, 2025
1 parent 91a4c8b commit 7e7ccc5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dascore/viz/spectrogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def spectrogram(
spec = _spec.aggregate(other_dim, method="mean").squeeze()
else:
raise ValueError(
f"The aggr_domain '{aggr_domain}' should be either 'time' or 'frequency'."
f"The aggr_domain '{aggr_domain}' should be 'time' or 'frequency.'"
)
else:
spec = patch.spectrogram(dim)
Expand Down
7 changes: 5 additions & 2 deletions tests/test_viz/test_spectrogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,21 @@


def test_get_other_dim_valid():
"""Ensure _get_other_dim correctly returns the other dimension."""
dims = ("time", "distance")
assert _get_other_dim("time", dims) == "distance"
assert _get_other_dim("distance", dims) == "time"


def test_get_other_dim_invalid():
"""Ensure _get_other_dim raises a ValueError."""
dims = ("time", "distance")
with pytest.raises(ValueError, match="not in patch's dimensions"):
_get_other_dim("frequency", dims)


def test_get_other_dim_invalid_dim_type():
"""Ensure _get_other_dim raises a TypeError when dim is not a string."""
dims = ("time", "distance")
with pytest.raises(TypeError, match="Expected 'dim' to be a string"):
_get_other_dim(("time",), dims)
Expand Down Expand Up @@ -53,11 +56,11 @@ def test_invalid_aggr_domain(self, random_patch):

def test_invalid_patch_dims(self, random_patch):
"""Ensure ValueError is raised for patches with invalid dimensions."""
patch_3D = random_patch.correlate(distance=[0, 1])
patch_3d = random_patch.correlate(distance=[0, 1])
with pytest.raises(
ValueError, match="Can only make spectogram of 1D or 2D patches"
):
patch_3D.viz.spectrogram(dim="distance")
patch_3d.viz.spectrogram(dim="distance")

def test_1d_patch(self, random_patch):
"""Ensure spectrogram works with 1D patch."""
Expand Down

0 comments on commit 7e7ccc5

Please sign in to comment.