Skip to content

Commit 4e0571f

Browse files
committed
run black
1 parent 584d177 commit 4e0571f

File tree

15 files changed

+624
-467
lines changed

15 files changed

+624
-467
lines changed

doc/source/pyplots/tutorial.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
1-
21
notebook.width = 10
3-
plt.rcParams['figure.figsize'] = (notebook.width, 3)
2+
plt.rcParams["figure.figsize"] = (notebook.width, 3)
43

54
# only display [0, 20] timerange
65
notebook.crop = Segment(0, 40)
76

87
# plot reference
98
plt.subplot(211)
109
reference = Annotation()
11-
reference[Segment(0, 10)] = 'A'
12-
reference[Segment(12, 20)] = 'B'
13-
reference[Segment(24, 27)] = 'A'
14-
reference[Segment(30, 40)] = 'C'
10+
reference[Segment(0, 10)] = "A"
11+
reference[Segment(12, 20)] = "B"
12+
reference[Segment(24, 27)] = "A"
13+
reference[Segment(30, 40)] = "C"
1514
notebook.plot_annotation(reference, legend=True, time=False)
16-
plt.gca().text(0.6, 0.15, 'reference', fontsize=16)
15+
plt.gca().text(0.6, 0.15, "reference", fontsize=16)
1716

1817
# plot hypothesis
1918
plt.subplot(212)
2019
hypothesis = Annotation()
21-
hypothesis[Segment(2, 13)] = 'a'
22-
hypothesis[Segment(13, 14)] = 'd'
23-
hypothesis[Segment(14, 20)] = 'b'
24-
hypothesis[Segment(22, 38)] = 'c'
25-
hypothesis[Segment(38, 40)] = 'd'
20+
hypothesis[Segment(2, 13)] = "a"
21+
hypothesis[Segment(13, 14)] = "d"
22+
hypothesis[Segment(14, 20)] = "b"
23+
hypothesis[Segment(22, 38)] = "c"
24+
hypothesis[Segment(38, 40)] = "d"
2625
notebook.plot_annotation(hypothesis, legend=True, time=True)
27-
plt.gca().text(0.6, 0.15, 'hypothesis', fontsize=16)
26+
plt.gca().text(0.6, 0.15, "hypothesis", fontsize=16)
2827

2928
plt.show()

src/pyannote/metrics/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from .base import f_measure
3030

3131
import importlib.metadata
32+
3233
__version__ = importlib.metadata.version("pyannote-metrics")
3334

3435
__all__ = ["f_measure"]

src/pyannote/metrics/base.py

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ class BaseMetric:
5050
def metric_name(cls) -> str:
5151
raise NotImplementedError(
5252
cls.__name__ + " is missing a 'metric_name' class method. "
53-
"It should return the name of the metric as string."
53+
"It should return the name of the metric as string."
5454
)
5555

5656
@classmethod
5757
def metric_components(cls) -> MetricComponents:
5858
raise NotImplementedError(
5959
cls.__name__ + " is missing a 'metric_components' class method. "
60-
"It should return the list of names of metric components."
60+
"It should return the list of names of metric components."
6161
)
6262

6363
def __init__(self, **kwargs):
@@ -84,9 +84,14 @@ def name(self):
8484
# TODO: use joblib/locky to allow parallel processing?
8585
# TODO: signature could be something like __call__(self, reference_iterator, hypothesis_iterator, ...)
8686

87-
def __call__(self, reference: Union[Timeline, Annotation],
88-
hypothesis: Union[Timeline, Annotation],
89-
detailed: bool = False, uri: Optional[str] = None, **kwargs):
87+
def __call__(
88+
self,
89+
reference: Union[Timeline, Annotation],
90+
hypothesis: Union[Timeline, Annotation],
91+
detailed: bool = False,
92+
uri: Optional[str] = None,
93+
**kwargs,
94+
):
9095
"""Compute metric value and accumulate components
9196
9297
Parameters
@@ -247,10 +252,12 @@ def __iter__(self):
247252
for uri, component in self.results_:
248253
yield uri, component
249254

250-
def compute_components(self,
251-
reference: Union[Timeline, Annotation],
252-
hypothesis: Union[Timeline, Annotation],
253-
**kwargs) -> Details:
255+
def compute_components(
256+
self,
257+
reference: Union[Timeline, Annotation],
258+
hypothesis: Union[Timeline, Annotation],
259+
**kwargs,
260+
) -> Details:
254261
"""Compute metric components
255262
256263
Parameters
@@ -269,8 +276,8 @@ def compute_components(self,
269276
"""
270277
raise NotImplementedError(
271278
self.__class__.__name__ + " is missing a 'compute_components' method."
272-
"It should return a dictionary where keys are component names "
273-
"and values are component values."
279+
"It should return a dictionary where keys are component names "
280+
"and values are component values."
274281
)
275282

276283
def compute_metric(self, components: Details):
@@ -289,12 +296,13 @@ def compute_metric(self, components: Details):
289296
"""
290297
raise NotImplementedError(
291298
self.__class__.__name__ + " is missing a 'compute_metric' method. "
292-
"It should return the actual value of the metric based "
293-
"on the precomputed component dictionary given as input."
299+
"It should return the actual value of the metric based "
300+
"on the precomputed component dictionary given as input."
294301
)
295302

296-
def confidence_interval(self, alpha: float = 0.9) \
297-
-> Tuple[float, Tuple[float, float]]:
303+
def confidence_interval(
304+
self, alpha: float = 0.9
305+
) -> Tuple[float, Tuple[float, float]]:
298306
"""Compute confidence interval on accumulated metric values
299307
300308
Parameters
@@ -319,13 +327,17 @@ def confidence_interval(self, alpha: float = 0.9) \
319327
values = [r[self.metric_name_] for _, r in self.results_]
320328

321329
if len(values) == 0:
322-
raise ValueError("Please evaluate a bunch of files before computing confidence interval.")
323-
330+
raise ValueError(
331+
"Please evaluate a bunch of files before computing confidence interval."
332+
)
333+
324334
elif len(values) == 1:
325-
warnings.warn("Cannot compute a reliable confidence interval out of just one file.")
335+
warnings.warn(
336+
"Cannot compute a reliable confidence interval out of just one file."
337+
)
326338
center = lower = upper = values[0]
327339
return center, (lower, upper)
328-
340+
329341
else:
330342
return scipy.stats.bayes_mvs(values, alpha=alpha)[0]
331343

src/pyannote/metrics/cli.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,12 @@
9797

9898
import numpy as np
9999
import pandas as pd
100+
100101
# command line parsing
101102
from docopt import docopt
102103
from pyannote.core import Annotation
103104
from pyannote.core import Timeline
105+
104106
# evaluation protocols
105107
from pyannote.database import get_protocol
106108
from pyannote.database.util import get_annotated

0 commit comments

Comments
 (0)