For remove_pd_object, we can combine if and elif, since both of them will do the same thing, ret[n] = v.
For enumerate_variables:
if len(variables) == 0 can be replaced by if not variables.
since constant_name and constant_vars will not be modified later, so we can construct a dictionary constant_d in advance instead of constructing the same dictionary in the following list comprehension.
For enumerate_signal, if len(tuples) != 0 can be replaced by if tuples .
For stop_early, we can construct stop_vars_set = {'sl_stop', 'ts_stop', 'tp_stop'} once, and use it for the following loop.
remove_pd_object
, we can combineif
andelif
, since both of them will do the same thing,ret[n] = v
.enumerate_variables
:if len(variables) == 0
can be replaced byif not variables
.constant_name
andconstant_vars
will not be modified later, so we can construct a dictionaryconstant_d
in advance instead of constructing the same dictionary in the following list comprehension.enumerate_signal
,if len(tuples) != 0
can be replaced byif tuples
.stop_early
, we can constructstop_vars_set = {'sl_stop', 'ts_stop', 'tp_stop'}
once, and use it for the following loop.