Skip to content

Commit 2fd16ce

Browse files
committed
Replaced deprecated np.in1d with np.isin
1 parent 3047689 commit 2fd16ce

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

ibicus/debias/_isimip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1382,7 +1382,7 @@ def apply_location(
13821382
years_cm_future=years_cm_future[indices_window_cm_future],
13831383
)[
13841384
np.logical_and(
1385-
np.in1d(
1385+
np.isin(
13861386
indices_window_cm_future, indices_bias_corrected_values
13871387
),
13881388
get_mask_for_unique_subarray(indices_window_cm_future),

ibicus/evaluate/metrics.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def _check_completeness_of_time_categories_and_warn(thresholds, threshold_scope)
190190
if threshold_scope == "day":
191191
days_of_year = np.arange(1, 367)
192192
if not all(
193-
mask_days_of_year_in_quantiles := np.in1d(
193+
mask_days_of_year_in_quantiles := np.isin(
194194
days_of_year, list(thresholds.keys())
195195
)
196196
):
@@ -201,7 +201,7 @@ def _check_completeness_of_time_categories_and_warn(thresholds, threshold_scope)
201201
elif threshold_scope == "month":
202202
months = np.arange(1, 13)
203203
if not all(
204-
mask_months_in_quantiles := np.in1d(months, list(thresholds.keys()))
204+
mask_months_in_quantiles := np.isin(months, list(thresholds.keys()))
205205
):
206206
warnings.warn(
207207
"Not all months present inside the dataset used for initialisation. Not threshold defined for months %s"
@@ -210,7 +210,7 @@ def _check_completeness_of_time_categories_and_warn(thresholds, threshold_scope)
210210
elif threshold_scope == "season":
211211
seasons = np.array(["Spring", "Summer", "Autumn", "Winter"])
212212
if not all(
213-
mask_seasons_in_quantiles := np.in1d(seasons, list(thresholds.keys()))
213+
mask_seasons_in_quantiles := np.isin(seasons, list(thresholds.keys()))
214214
):
215215
warnings.warn(
216216
"Not all seasons present inside the dataset used for initialisation. Not threshold defined for seasons %s"
@@ -349,7 +349,7 @@ def _get_mask_higher_or_lower(self, x, threshold_value, higher_or_lower, time=No
349349

350350
time = ThresholdMetric._get_time_group_by_scope(time, self.threshold_scope)
351351

352-
if not np.all(np.in1d(time, list(threshold_value.keys()))):
352+
if not np.all(np.isin(time, list(threshold_value.keys()))):
353353
raise ValueError(
354354
"time contains values for %ss for which no thresholds exist in self.threshold_value"
355355
% self.threshold_scope

ibicus/utils/_running_window_mode.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def get_if_in_chosen_years(years, chosen_years):
165165
chosen_years : np.ndarray
166166
Array of chosen years.
167167
"""
168-
return np.in1d(years, chosen_years)
168+
return np.isin(years, chosen_years)
169169

170170
def use(self, years):
171171
"""
@@ -337,7 +337,7 @@ def get_indices_vals_in_window(
337337
)
338338
window_range[window_range == 0] = 366
339339

340-
return np.where(np.in1d(days_of_year, window_range))[0]
340+
return np.where(np.isin(days_of_year, window_range))[0]
341341

342342
def get_indices_vals_to_adjust(
343343
self, days_of_year: np.ndarray, window_center: int
@@ -358,12 +358,12 @@ def get_indices_vals_to_adjust(
358358
)
359359
window_range = window_range[(window_range >= 0) & (window_range <= 366)]
360360

361-
return np.where(np.in1d(days_of_year, window_range))[0]
361+
return np.where(np.isin(days_of_year, window_range))[0]
362362

363363
@staticmethod
364364
def get_mask_vals_to_adjust_in_window(indices_window, indices_vals_to_correct):
365365
return np.logical_and(
366-
np.in1d(indices_window, indices_vals_to_correct),
366+
np.isin(indices_window, indices_vals_to_correct),
367367
get_mask_for_unique_subarray(indices_window),
368368
)
369369

tests/test_running_window_mode.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def _test_all_bias_corrected_and_length_each_window(
156156
assert len(np.unique(debiased_years)) == len(debiased_years)
157157

158158
# Check that all years are given
159-
assert all(np.in1d(years, debiased_years))
159+
assert all(np.isin(years, debiased_years))
160160

161161
def test_use(self):
162162
for step_length in range(1, 10):
@@ -215,7 +215,7 @@ def _test_all_bias_corrected_and_length_each_window(
215215
indices_vals_in_window = window.get_indices_vals_in_window(
216216
days_of_year_dates, window_center
217217
)
218-
assert np.all(np.in1d(indices_vals_to_debias, indices_vals_in_window))
218+
assert np.all(np.isin(indices_vals_to_debias, indices_vals_in_window))
219219

220220
n_occurrences = (days_of_year_dates == window_center).sum()
221221
if length > 365:

0 commit comments

Comments
 (0)