Skip to content

Commit

Permalink
Combined if statements for list and array
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Jorgensen committed May 7, 2024
1 parent a383936 commit c5480cc
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/skmatter/_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,7 @@ def _init_greedy_search(self, X, y, n_to_select):
self.hausdorff_ = np.full(X.shape[self._axis], np.inf)
self.hausdorff_at_select_ = np.full(X.shape[self._axis], np.inf)

if isinstance(self.initialize, np.ndarray):
if isinstance(self.initialize, (np.ndarray, list)):
if all(isinstance(i, numbers.Integral) for i in self.initialize):
for i, val in enumerate(self.initialize):
self.selected_idx_[i] = val
Expand All @@ -1054,13 +1054,6 @@ def _init_greedy_search(self, X, y, n_to_select):
initialize = self.initialize
self.selected_idx_[0] = initialize
self._update_post_selection(X, y, self.selected_idx_[0])
elif isinstance(self.initialize, list) and all(
[isinstance(i, numbers.Integral) for i in self.initialize]
):
for i, val in enumerate(self.initialize):
self.selected_idx_[i] = val
self._update_post_selection(X, y, self.selected_idx_[i])

else:
raise ValueError("Invalid value of the initialize parameter")

Expand Down

0 comments on commit c5480cc

Please sign in to comment.