theislab / scvelo

RNA Velocity generalized through dynamical modeling
https://scvelo.org
BSD 3-Clause "New" or "Revised" License
417 stars 102 forks source link

Variable referenced before assignment in `_get_rep` #796

Closed WeilerP closed 2 years ago

WeilerP commented 2 years ago

Description

In scvelo/preprocessing/neighbors.py::_get_rep, the variable rep is referenced before assigned when not entering the if-else clause.

import scvelo as scv
from scvelo.preprocessing.neighbors import _get_rep

adata = scv.datasets.pancreas()
use_rep = _get_rep(adata, use_rep="random", n_pcs=None)
Error output ```pytb --------------------------------------------------------------------------- UnboundLocalError Traceback (most recent call last) in 1 adata = scv.datasets.pancreas() ----> 2 use_rep = _get_rep(adata, use_rep="random", n_pcs=None) ~/code/scvelo/scvelo/preprocessing/neighbors.py in _get_rep(adata, use_rep, n_pcs) 77 ) 78 ---> 79 return rep 80 81 UnboundLocalError: local variable 'rep' referenced before assignment ```
Versions ```pytb scvelo==0.2.5.dev56+g9ff8098.d20211206 scanpy==1.7.2 anndata==0.7.6 loompy==3.0.6 numpy==1.20.3 scipy==1.6.3 matplotlib==3.4.2 sklearn==0.24.2 pandas==1.2.4 ```
WeilerP commented 2 years ago

Closed via #797.