diff --git a/src/evaluate/module.py b/src/evaluate/module.py index b13faccdb..1ec0e4cfc 100644 --- a/src/evaluate/module.py +++ b/src/evaluate/module.py @@ -559,7 +559,7 @@ def _infer_feature_from_example(self, example): self._enforce_nested_string_type(features, example) features.encode_example(example) return features - except ValueError: + except (ValueError, TypeError): continue feature_strings = "\n".join([f"Feature option {i}: {feature}" for i, feature in enumerate(self.features)]) error_msg = ( diff --git a/tests/test_metric.py b/tests/test_metric.py index c76b9de97..07c1e241b 100644 --- a/tests/test_metric.py +++ b/tests/test_metric.py @@ -554,6 +554,16 @@ def test_multiple_features(self): preds, refs = DummyMetric.predictions_and_references() expected_results = DummyMetric.expected_results() self.assertDictEqual(expected_results, metric.compute(predictions=preds, references=refs)) + + metric.info.features = [ + Features({"predictions": Value("string"), "references": Value("string")}), + Features({"predictions": Value("int64"), "references": Value("int64")}), + ] + + preds, refs = DummyMetric.predictions_and_references() + expected_results = DummyMetric.expected_results() + self.assertDictEqual(expected_results, metric.compute(predictions=preds, references=refs)) + del metric