Consider merging collapsible if statements
224 "rolling_volatility",
225 ]
226
227 if function not in unnecessary_function_calls:228 if rf > 0:
229 return to_excess_returns(data, rf, nperiods)
230 return data
Consider merging collapsible if statements
1217 strategy_colname = kwargs.get("strategy_title", "Strategy")
1218 active = kwargs.get("active", "False")
1219
1220 if isinstance(returns, _pd.DataFrame):1221 if len(returns.columns) > 1:
1222 if isinstance(strategy_colname, str):
1223 strategy_colname = list(returns.columns)
Consider merging collapsible if statements
667 strategy_title = kwargs.get("strategy_title", "Strategy")
668 active = kwargs.get("active_returns", "False")
669
670 if isinstance(returns, _pd.DataFrame): 671 if len(returns.columns) > 1 and isinstance(strategy_title, str):
672 strategy_title = list(returns.columns)
673
Consider merging collapsible if statements
517 strategy_title = kwargs.get("strategy_title", "Strategy")
518 active = kwargs.get("active_returns", "False")
519
520 if isinstance(returns, _pd.DataFrame): 521 if len(returns.columns) > 1 and isinstance(strategy_title, str):
522 strategy_title = list(returns.columns)
523
Consider merging collapsible if statements
86 returns = _utils._prepare_returns(returns)
87
88 strategy_title = kwargs.get("strategy_title", "Strategy")
89 if isinstance(returns, _pd.DataFrame): 90 if len(returns.columns) > 1 and isinstance(strategy_title, str):
91 strategy_title = list(returns.columns)
92
Consider merging collapsible if statements
188 # rotate and align the tick labels so they look better
189 fig.autofmt_xdate()
190
191 if hline is not None: 192 if not isinstance(hline, _pd.Series):
193 if grayscale:
194 hlcolor = "gray"
Consider merging collapsible if statements
347 # use a more precise date string for the x axis locations in the toolbar
348 # ax.fmt_xdata = _mdates.DateFormatter('%Y-%m-%d')
349
350 if hline is not None: 351 if not isinstance(hline, _pd.Series):
352 if grayscale:
353 hlcolor = "black"
Consider merging collapsible if statements
680 color="gray",
681 )
682
683 if hline is not None: 684 if not isinstance(hline, _pd.Series):
685 if grayscale:
686 hlcolor = "black"
Description
Nested if
statements can be collapsed into a single if
statement by separating their condition using and
operator.
Merging collapsible if
statements increases the code's readability.
Bad practice
if condition1:
if condition2:
dosomething()
Preferred
if condition1 and condition2:
dosomething()
Exception:
DeepSource will not raise this issue when the nested if
statements have comments in between them, as it could be explaining why the nested if
is in place.