From 0172d4dac0ca823e8bd293cfd4d28e78d92efe42 Mon Sep 17 00:00:00 2001 From: mariosasko Date: Wed, 12 Jul 2023 17:45:10 +0200 Subject: [PATCH] Fix `ClassLabel` min max check for `None` values --- src/datasets/features/features.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/datasets/features/features.py b/src/datasets/features/features.py index dd41be8bd95..0b2d0e27820 100644 --- a/src/datasets/features/features.py +++ b/src/datasets/features/features.py @@ -1095,7 +1095,7 @@ def cast_storage(self, storage: Union[pa.StringArray, pa.IntegerArray]) -> pa.In """ if isinstance(storage, pa.IntegerArray) and len(storage) > 0: min_max = pc.min_max(storage).as_py() - if min_max["max"] >= self.num_classes: + if min_max["max"] is not None and min_max["max"] >= self.num_classes: raise ValueError( f"Class label {min_max['max']} greater than configured num_classes {self.num_classes}" )