Skip to content

Commit 3b67575

Browse files
committed
Merge branch 'develop' of github.com:pyannote/pyannote-core into develop
2 parents 56480ab + 83e5286 commit 3b67575

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

pyannote/core/notebook.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ def plot_feature(
341341
):
342342

343343
if not self.crop:
344-
self.crop = feature.getExtent()
344+
self.crop = feature.extent
345345

346346
window = feature.sliding_window
347347
n, dimension = feature.data.shape
@@ -442,7 +442,8 @@ def repr_feature(feature: SlidingWindowFeature):
442442

443443
plt.rcParams["figure.figsize"] = (notebook.width, 1.5 * num_overlap)
444444

445-
fig, axes = plt.subplots(nrows=num_overlap, ncols=1,)
445+
fig, axes = plt.subplots(nrows=num_overlap, ncols=1, squeeze=False)
446+
axes = axes.flatten()
446447
mini, maxi = np.nanmin(feature.data), np.nanmax(feature.data)
447448
ylim = (mini - 0.2 * (maxi - mini), maxi + 0.2 * (maxi - mini))
448449
for c, (window, data) in enumerate(feature):

tests/test_features.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ def features():
1111
window = SlidingWindow(start=0., step=1., duration=2.)
1212
return SlidingWindowFeature(data, window)
1313

14+
@pytest.fixture
15+
def one_feature():
16+
return SlidingWindowFeature(
17+
np.array([ [[0, 0, 0]], [[1, 1, 1]] ]),
18+
SlidingWindow()
19+
)
20+
1421
@pytest.fixture
1522
def segment():
1623
return Segment(3.3, 6.7)
@@ -47,3 +54,23 @@ def test_crop_fixed_out_of_bounds(features):
4754
expected = np.array([[0, 0, 0, 0, 1, 2, 3, 4, 5],
4855
[10, 10, 10, 10, 11, 12, 13, 14, 15]]).T
4956
np.testing.assert_array_equal(expected, actual)
57+
58+
def test_repr_png(features):
59+
try:
60+
import matplotlib
61+
import IPython
62+
except ModuleNotFoundError:
63+
pytest.skip("notebook dependencies not available")
64+
expected = b'\x89PNG'
65+
actual = features._repr_png_()[:4]
66+
assert expected == actual
67+
68+
def test_repr_png_one_feature(one_feature):
69+
try:
70+
import matplotlib
71+
import IPython
72+
except ModuleNotFoundError:
73+
pytest.skip("notebook dependencies not available")
74+
expected = b'\x89PNG'
75+
actual = one_feature._repr_png_()[:4]
76+
assert expected == actual

0 commit comments

Comments
 (0)