Skip to content

Commit

Permalink
Change the method to counter the None str + object presents
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-narozniak committed Apr 26, 2024
1 parent 86b7d7e commit c031420
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions datasets/flwr_datasets/partitioner/natural_id_partitioner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit c031420

Please sign in to comment.