@@ -193,7 +193,8 @@ def _import_name(name: str) -> Any:
193193
194194 parts = name .split ("." )
195195 obj = import_module (parts [0 ])
196- for i , name in enumerate (parts [1 :]):
196+ for _i , name in enumerate (parts [1 :]):
197+ i = _i
197198 try :
198199 obj = import_module (f"{ obj .__name__ } .{ name } " )
199200 except ModuleNotFoundError :
@@ -203,9 +204,9 @@ def _import_name(name: str) -> Any:
203204 for name in parts [i + 1 :]:
204205 try :
205206 obj = getattr (obj , name )
206- except AttributeError :
207+ except AttributeError as e :
207208 msg = f"{ parts [:i ]} , { parts [i + 1 :]} , { obj } { name } "
208- raise RuntimeError (msg )
209+ raise RuntimeError (msg ) from e
209210 return obj
210211
211212
@@ -312,7 +313,7 @@ def get_igraph_from_adjacency(adjacency: CSBase, *, directed: bool = False) -> G
312313 weights = weights .A1
313314 g = ig .Graph (directed = directed )
314315 g .add_vertices (adjacency .shape [0 ]) # this adds adjacency.shape[0] vertices
315- g .add_edges (list (zip (sources , targets )))
316+ g .add_edges (list (zip (sources , targets , strict = True )))
316317 with suppress (KeyError ):
317318 g .es ["weight" ] = weights
318319 if g .vcount () != adjacency .shape [0 ]:
@@ -450,9 +451,9 @@ def identify_groups(ref_labels, pred_labels, *, return_overlaps: bool = False):
450451
451452 """
452453 ref_unique , ref_counts = np .unique (ref_labels , return_counts = True )
453- ref_dict = dict (zip (ref_unique , ref_counts ))
454+ ref_dict = dict (zip (ref_unique , ref_counts , strict = True ))
454455 pred_unique , pred_counts = np .unique (pred_labels , return_counts = True )
455- pred_dict = dict (zip (pred_unique , pred_counts ))
456+ pred_dict = dict (zip (pred_unique , pred_counts , strict = True ))
456457 associated_predictions = {}
457458 associated_overlaps = {}
458459 for ref_label in ref_unique :
@@ -736,7 +737,9 @@ def _(
736737 )
737738 )
738739 ):
739- warnings .warn ("Rechunking scaling_array in user operation" , UserWarning )
740+ warnings .warn (
741+ "Rechunking scaling_array in user operation" , UserWarning , stacklevel = 3
742+ )
740743 scaling_array = scaling_array .rechunk (make_axis_chunks (X , axis ))
741744 else :
742745 scaling_array = da .from_array (
@@ -889,8 +892,8 @@ def select_groups(
889892 )
890893 for iname , name in enumerate (adata .obs [key ].cat .categories ):
891894 # if the name is not found, fallback to index retrieval
892- if adata . obs [ key ]. cat . categories [ iname ] in adata .obs [key ].values :
893- mask_obs = adata . obs [ key ]. cat . categories [ iname ] == adata .obs [key ].values
895+ if name in adata .obs [key ].values :
896+ mask_obs = name == adata .obs [key ].values
894897 else :
895898 mask_obs = str (iname ) == adata .obs [key ].values
896899 groups_masks_obs [iname ] = mask_obs
0 commit comments