Skip to content

Commit 47aac27

Browse files
committed
replace try/except with if/else
1 parent 8d89a72 commit 47aac27

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

tests/test_groupby.py

+4-13
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def df2scalar(val: DataFrame) -> float:
246246
)
247247

248248
# interpolate
249-
try:
249+
if PD_LTE_22:
250250
check(assert_type(GB_DF.resample("ME").interpolate(), DataFrame), DataFrame)
251251
check(
252252
assert_type(
@@ -258,12 +258,7 @@ def df2scalar(val: DataFrame) -> float:
258258
assert_type(GB_DF.resample("ME").interpolate(inplace=True), None),
259259
type(None),
260260
)
261-
except NotImplementedError:
262-
# In version 3.0, this is not allowed
263-
if PD_LTE_22:
264-
raise RuntimeError("Should not happen")
265-
266-
if not PD_LTE_22:
261+
else:
267262

268263
def resample_interpolate(x: DataFrame) -> DataFrame:
269264
return x.resample("ME").interpolate()
@@ -427,7 +422,7 @@ def f(val: Series) -> float:
427422
check(assert_type(GB_S.resample("ME").asfreq(-1.0), "Series[float]"), Series, float)
428423

429424
# interpolate
430-
try:
425+
if PD_LTE_22:
431426
check(
432427
assert_type(GB_S.resample("ME").interpolate(), "Series[float]"),
433428
Series,
@@ -436,11 +431,7 @@ def f(val: Series) -> float:
436431
check(
437432
assert_type(GB_S.resample("ME").interpolate(inplace=True), None), type(None)
438433
)
439-
except NotImplementedError:
440-
if PD_LTE_22:
441-
raise RuntimeError("should not happen")
442-
443-
if not PD_LTE_22:
434+
else:
444435
check(
445436
assert_type(
446437
GB_S.apply(lambda x: x.resample("ME").interpolate()), "Series[float]"

0 commit comments

Comments
 (0)