Skip to content

Commit

Permalink
Delay transforming priority_order into ndarray
Browse files Browse the repository at this point in the history
In the changed code, we had a mypy error because numpy ndarrays are not
compatible with random.Random.shuffle() (expected argument type is
MutableSequence[Any])

We fix this by first instantiating priority_order as a list, then
shuffling it, then creating an ndarray from it afterwards.
  • Loading branch information
junholee6a committed Oct 26, 2023
1 parent 5f62f03 commit d2c6e49
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions dataprofiler/labelers/data_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2047,9 +2047,9 @@ def process(
elif aggregation_func == "random":
num_labels = max(label_mapping.values()) + 1
random_state: random.Random = self._parameters["random_state"]
priority_order = np.array(list(range(num_labels)))
random_state.shuffle(priority_order) # type: ignore
self.priority_prediction(results, priority_order)
priority_order = list(range(num_labels))
random_state.shuffle(priority_order)
self.priority_prediction(results, np.array(priority_order))
else:
raise ValueError(
f"`{aggregation_func}` is not a valid aggregation function"
Expand Down

0 comments on commit d2c6e49

Please sign in to comment.