From c0314209efce4dbcd8651eb9cec1d309662d4c4c Mon Sep 17 00:00:00 2001 From: Adam Narozniak Date: Fri, 26 Apr 2024 10:04:41 +0200 Subject: [PATCH] Change the method to counter the None str + object presents --- .../flwr_datasets/partitioner/natural_id_partitioner.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/datasets/flwr_datasets/partitioner/natural_id_partitioner.py b/datasets/flwr_datasets/partitioner/natural_id_partitioner.py index f6a44cd8e622..86827c748be9 100644 --- a/datasets/flwr_datasets/partitioner/natural_id_partitioner.py +++ b/datasets/flwr_datasets/partitioner/natural_id_partitioner.py @@ -70,11 +70,15 @@ def _create_partition_id_to_indices(self) -> None: none_replacement: Union[int, str] if dtype == "string": none_replacement = "None" + new_term = "" + counter = 0 # Ensure the replacement is not in the dataset while True: - if none_replacement not in unique_natural_ids: + if none_replacement + new_term not in unique_natural_ids: + none_replacement = none_replacement + new_term break - none_replacement += "1" + counter += 1 + new_term = f"{counter}" elif "unit" in dtype: none_replacement = max(natural_ids) + 1 elif "int" in dtype: