StatBiomed / UniTVelo

UniTVelo, Temporally Unified RNA Velocity for single cell trajectory inference
https://unitvelo.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
25 stars 9 forks source link

Sub-conditions issue with ifs #29

Closed idriskb closed 1 year ago

idriskb commented 1 year ago
if (iter > self.agenes_thres) & \
    (iter == self.config.MAX_ITER - 1 or \
    tf.math.reduce_all(stop_cond) == True or \
    min(self.se[self.agenes_thres + 1:]) * 1.1 < self.se[-1] 
        if (iter > self.agenes_thres + 1) else False):

this whole block will return always falseif (iter > self.agenes_thres + 1) is False.

It is either a missing parenthesis

(min(self.se[self.agenes_thres + 1:]) * 1.1 < self.se[-1] 
        if (iter > self.agenes_thres + 1) else False))

meaning that the in-line if is evaluated for the 3rd subcondition.

Otherwise if this was intentional it should be written as:

if (iter > self.agenes_thres+1) & \
    (iter == self.config.MAX_ITER - 1 or \
    tf.math.reduce_all(stop_cond) == True or \
    min(self.se[self.agenes_thres + 1:]) * 1.1 < self.se[-1] ):

with no need to do two ifs