Skip to content

Commit

Permalink
address DeprecationWarning: 'Conversion of an array'
Browse files Browse the repository at this point in the history
  • Loading branch information
jGaboardi committed Jan 15, 2024
1 parent 41f9e5c commit 697a05b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 10 additions & 2 deletions spopt/region/azp.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,11 @@ def _azp_connected_component(self, adj, initial_clustering, attr): # noqa: ARG0

# step 7: Repeat until no further improving moves are made
while obj_val_end < obj_val_start: # improvement
obj_val_start = float(obj_val_end)
obj_val_start = (
float(obj_val_end.item())
if isinstance(obj_val_end, np.ndarray)
else float(obj_val_end)
)
distinct_regions = distinct_regions_copy.copy()
# step 6: when the list for region K is exhausted return to step 3
# and select another region and repeat steps 4-6
Expand Down Expand Up @@ -574,7 +578,11 @@ def _azp_connected_component(self, adj, initial_clustering, attr): # noqa: ARG0
else:
break

obj_val_end = float(self.allow_move_strategy.objective_val)
obj_val_end = (
float(self.allow_move_strategy.objective_val.item())
if isinstance(self.allow_move_strategy.objective_val, np.ndarray)
else float(self.allow_move_strategy.objective_val)
)
return labels


Expand Down
6 changes: 5 additions & 1 deletion spopt/region/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,11 @@ def count(arr, el):
unique, counts = np.unique(arr, return_counts=True)
idx = np.where(unique == el)[0]
if len(idx) > 0:
return int(counts[idx])
return (
int(counts[idx].item())
if isinstance(counts[idx], np.ndarray)
else int(counts[idx])
)
return 0


Expand Down

0 comments on commit 697a05b

Please sign in to comment.