Skip to content

Commit

Permalink
Speedup concordance_cc() and pearson_cc() (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
hagenw authored Apr 25, 2023
1 parent 3faf18f commit 23fdfc5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions audmetric/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ def concordance_cc(
"""
assert_equal_length(truth, prediction)

prediction = np.array(list(prediction))
truth = np.array(list(truth))
if not isinstance(truth, np.ndarray):
truth = np.array(list(truth))
if not isinstance(prediction, np.ndarray):
prediction = np.array(list(prediction))

if len(prediction) < 2:
return np.NaN
Expand Down Expand Up @@ -672,8 +674,10 @@ def pearson_cc(
"""
assert_equal_length(truth, prediction)

prediction = np.array(list(prediction))
truth = np.array(list(truth))
if not isinstance(truth, np.ndarray):
truth = np.array(list(truth))
if not isinstance(prediction, np.ndarray):
prediction = np.array(list(prediction))

if len(prediction) < 2 or prediction.std() == 0:
return np.NaN
Expand Down

0 comments on commit 23fdfc5

Please sign in to comment.