3
3
import inspect
4
4
from contextlib import nullcontext
5
5
6
+ cb_create_call_stack_context_manager = None
6
7
cb_notify_dataframe_method_call = None
7
8
cb_notify_series_method_call = None
8
- stack_counter_context = None
9
9
10
10
def register_dataframe_method (method ):
11
11
"""Register a function as a method attached to the Pandas DataFrame.
@@ -30,13 +30,12 @@ def __init__(self, pandas_obj):
30
30
31
31
@wraps (method )
32
32
def __call__ (self , * args , ** kwargs ):
33
- global stack_counter_context_manager
34
- with stack_counter_context . get_sc ( ) if stack_counter_context else nullcontext () as sc :
33
+ global cb_create_call_stack_context_manager
34
+ with cb_create_call_stack_context_manager ( method . __name__ ) if cb_create_call_stack_context_manager else nullcontext () as sc :
35
35
method_call_obj = None
36
36
global cb_notify_dataframe_method_call
37
37
if cb_notify_dataframe_method_call :
38
- stack_depth = sc .scf .level
39
- method_call_obj = cb_notify_dataframe_method_call (self ._obj , method .__name__ , method_signature , args , kwargs , stack_depth )
38
+ method_call_obj = cb_notify_dataframe_method_call (self ._obj , method .__name__ , method_signature , args , kwargs )
40
39
if method_call_obj :
41
40
new_args , new_kwargs = method_call_obj .handle_start_method_call ()
42
41
args = new_args [1 :]; kwargs = new_kwargs
@@ -69,13 +68,12 @@ def __init__(self, pandas_obj):
69
68
70
69
@wraps (method )
71
70
def __call__ (self , * args , ** kwargs ):
72
- global stack_counter_context_manager
73
- with stack_counter_context . get_sc ( ) if stack_counter_context else nullcontext () as sc :
71
+ global cb_create_call_stack_context_manager
72
+ with cb_create_call_stack_context_manager ( method . __name__ ) if cb_create_call_stack_context_manager else nullcontext () as sc :
74
73
method_call_obj = None
75
74
global cb_notify_series_method_call
76
75
if cb_notify_series_method_call :
77
- stack_depth = sc .scf .level
78
- method_call_obj = cb_notify_series_method_call (self ._obj , method .__name__ , method_signature , args , kwargs , stack_depth )
76
+ method_call_obj = cb_notify_series_method_call (self ._obj , method .__name__ , method_signature , args , kwargs )
79
77
if method_call_obj :
80
78
new_args , new_kwargs = method_call_obj .handle_start_method_call ()
81
79
args = new_args [1 :]; kwargs = new_kwargs
0 commit comments