Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions seqio/dataset_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1227,12 +1227,14 @@ def _all_metric_fns(
score_fns.append(metric_fn)
elif pos_args == ("targets", "predictions", "aux_values"):
predict_with_aux_fns.append(metric_fn)
elif pos_args == ("targets", "predictions", "inputs"):
predict_fns.append(metric_fn)
else:
raise ValueError(
"Metric functions must have positional arguments matching either "
"('targets', 'scores'), ('targets', 'predictions') or "
"('targets', 'predictions', 'aux_values'). "
f"Got: {pos_args}"
"Metric functions must have positional arguments matching either"
" ('targets', 'scores'), ('targets', 'predictions'), ('targets',"
" 'predictions', 'aux_values') or ('targets', 'predictions',"
f" 'inputs').Got: {pos_args}"
)
return predict_fns, score_fns, predict_with_aux_fns

Expand Down
7 changes: 4 additions & 3 deletions seqio/dataset_providers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,10 @@ def extra_arg_metric_fn(targets, predictions, extra_param):
return {}

expected_error_message_prefix = (
"Metric functions must have positional arguments matching either "
"('targets', 'scores'), ('targets', 'predictions') or ('targets', "
"'predictions', 'aux_values'). Got: "
"Metric functions must have positional arguments matching either"
" ('targets', 'scores'), ('targets', 'predictions'), ('targets',"
" 'predictions', 'aux_values') or ('targets', 'predictions', 'inputs')."
" Got: "
)

with self.assertRaisesWithLiteralMatch(
Expand Down
Loading