@@ -178,6 +178,8 @@ def compare(*args, **kwargs):
178178 names : list of str, optional
179179 Names for arrays or sessions being compared. Defaults to the name of the first objects found in the caller
180180 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).
181183
182184 Examples
183185 --------
@@ -190,6 +192,7 @@ def compare(*args, **kwargs):
190192
191193 title = kwargs .pop ('title' , '' )
192194 names = kwargs .pop ('names' , None )
195+ depth = kwargs .pop ('depth' , 0 )
193196 _app = QApplication .instance ()
194197 if _app is None :
195198 _app = qapplication ()
@@ -211,8 +214,8 @@ def get_name(i, obj, depth=0):
211214 return obj_names [0 ] if obj_names else '%s %d' % (default_name , i )
212215
213216 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 )]
216219 else :
217220 assert isinstance (names , list ) and len (names ) == len (args )
218221
0 commit comments