@@ -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
0 commit comments