Skip to content

Commit 5c753b4

Browse files
committed
added passing of stack depth to pandas method call handler
1 parent 3a959a8 commit 5c753b4

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

pandas_flavor/register.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,19 @@ def __call__(self, *args, **kwargs):
3030
#ipdb.set_trace()
3131

3232
method_call_obj = None
33-
if sc.scf.level == 1:
34-
global start_method_call
33+
global start_method_call
34+
stack_depth = sc.scf.level
35+
if stack_depth == 1:
3536
if start_method_call:
36-
method_call_obj = start_method_call(self._obj, method.__name__, args, kwargs)
37-
38-
ret = method(self._obj, *args, **kwargs)
37+
method_call_obj = start_method_call(self._obj, method.__name__, args, kwargs, stack_depth)
38+
ret = method(self._obj, *args, **kwargs)
39+
elif stack_depth == 2 and method.__name__ == 'copy':
40+
#ipdb.set_trace()
41+
if start_method_call:
42+
method_call_obj = start_method_call(self._obj, method.__name__, args, kwargs, stack_depth)
43+
ret = method(self._obj, *args, **kwargs)
44+
else:
45+
ret = method(self._obj, *args, **kwargs)
3946

4047
if method_call_obj:
4148
method_call_obj.handle_end_method_call(ret)
@@ -63,10 +70,11 @@ def __init__(self, pandas_obj):
6370
def __call__(self, *args, **kwargs):
6471
with stack_counter.global_scf.get_sc() as sc:
6572
method_call_obj = None
66-
if sc.scf.level <= 2:
73+
stack_depth = sc.scf.level
74+
if stack_depth <= 2:
6775
global start_method_call
6876
if start_method_call:
69-
method_call_obj = start_method_call(self._obj, method.__name__, args, kwargs)
77+
method_call_obj = start_method_call(self._obj, method.__name__, args, kwargs, stack_depth)
7078

7179
ret = method(self._obj, *args, **kwargs)
7280

0 commit comments

Comments
 (0)