@@ -178,6 +178,8 @@ def compare(*args, **kwargs):
178
178
names : list of str, optional
179
179
Names for arrays or sessions being compared. Defaults to the name of the first objects found in the caller
180
180
namespace which correspond to the passed objects.
181
+ depth : int, optional
182
+ Stack depth where to look for variables. Defaults to 0 (where this function was called).
181
183
182
184
Examples
183
185
--------
@@ -190,6 +192,7 @@ def compare(*args, **kwargs):
190
192
191
193
title = kwargs .pop ('title' , '' )
192
194
names = kwargs .pop ('names' , None )
195
+ depth = kwargs .pop ('depth' , 0 )
193
196
_app = QApplication .instance ()
194
197
if _app is None :
195
198
_app = qapplication ()
@@ -211,8 +214,8 @@ def get_name(i, obj, depth=0):
211
214
return obj_names [0 ] if obj_names else '%s %d' % (default_name , i )
212
215
213
216
if names is None :
214
- # depth= 2 because of the list comprehension
215
- names = [get_name (i , a , depth = 2 ) for i , a in enumerate (args )]
217
+ # depth + 2 because of the list comprehension
218
+ names = [get_name (i , a , depth = depth + 2 ) for i , a in enumerate (args )]
216
219
else :
217
220
assert isinstance (names , list ) and len (names ) == len (args )
218
221
0 commit comments