def test_zero_precision_recall():
 try:
  old_error_settings = np.seterr(all='raise')
  y_real = np.array([['a', 'b', 'c']])
  y_pred = np.array([[]])
  assert_array_almost_equal(precision_score(y_real, y_pred), 0.0, 2)
  assert_array_almost_equal(recall_score(y_real, y_pred), 0.0, 2)
  assert_array_almost_equal(f1_score(y_real, y_pred), 0.0, 2)
 finally:
  np.seterr(**old_error_settings)

def test_zero_precision_recall ( ) : try : old_error_settings = np . seterr ( all = 'raise' ) y_real = np . array ( [ [ 'a' , 'b' , 'c' ] ] ) y_pred = np . array ( [ [ ] ] ) assert_array_almost_equal ( precision_score ( y_real , y_pred ) , 0.0 , 2 ) assert_array_almost_equal ( recall_score ( y_real , y_pred ) , 0.0 , 2 ) assert_array_almost_equal ( f1_score ( y_real , y_pred ) , 0.0 , 2 ) finally : np . seterr ( ** old_error_settings )
check that pathological cases do not bring nans .