From 8e7af7604189ca2775f21bbf85a3e46d399f1331 Mon Sep 17 00:00:00 2001 From: Anatoly Myachev Date: Wed, 20 Sep 2023 15:32:31 +0200 Subject: [PATCH] use 'catch_warnings' Signed-off-by: Anatoly Myachev --- modin/core/dataframe/algebra/fold.py | 11 ++++++++++- modin/pandas/base.py | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/modin/core/dataframe/algebra/fold.py b/modin/core/dataframe/algebra/fold.py index 419a0b56903..1edae4c1300 100644 --- a/modin/core/dataframe/algebra/fold.py +++ b/modin/core/dataframe/algebra/fold.py @@ -13,6 +13,9 @@ """Module houses builder class for Fold operator.""" +import functools +import warnings + from .operator import Operator @@ -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. @@ -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), ) ) diff --git a/modin/pandas/base.py b/modin/pandas/base.py index 4446a72ab52..4047434fec4 100644 --- a/modin/pandas/base.py +++ b/modin/pandas/base.py @@ -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