Skip to content

Commit

Permalink
use 'catch_warnings'
Browse files Browse the repository at this point in the history
Signed-off-by: Anatoly Myachev <[email protected]>
  • Loading branch information
anmyachev committed Sep 20, 2023
1 parent f98a41e commit 8e7af76
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
11 changes: 10 additions & 1 deletion modin/core/dataframe/algebra/fold.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

"""Module houses builder class for Fold operator."""

import functools
import warnings

from .operator import Operator


Expand All @@ -35,6 +38,12 @@ def register(cls, fold_function):
Function that takes query compiler and executes Fold function.
"""

@functools.wraps(fold_function)
def fold_function_catch_warnings(*args, **kwargs):
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=FutureWarning)
return fold_function(*args, **kwargs)

def caller(query_compiler, fold_axis=None, *args, **kwargs):
"""
Execute Fold function against passed query compiler.
Expand All @@ -60,7 +69,7 @@ def caller(query_compiler, fold_axis=None, *args, **kwargs):
return query_compiler.__constructor__(
query_compiler._modin_frame.fold(
cls.validate_axis(fold_axis),
lambda x: fold_function(x, *args, **kwargs),
lambda x: fold_function_catch_warnings(x, *args, **kwargs),
)
)

Expand Down
3 changes: 2 additions & 1 deletion modin/pandas/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2558,8 +2558,9 @@ def rolling(
+ "Call the method without the axis keyword instead.",
FutureWarning,
)
else:
axis = 0

# with warnings.catch_warnings():
if win_type is not None:
from .window import Window

Expand Down

0 comments on commit 8e7af76

Please sign in to comment.