Consider merging collapsible if statements
226 "rolling_volatility",
227 ]
228
229 if function not in unnecessary_function_calls:230 if rf > 0:
231 return to_excess_returns(data, rf, nperiods)
232 return data
Consider merging collapsible if statements
1249 strategy_colname = kwargs.get("strategy_title", "Strategy")
1250 active = kwargs.get("active", "False")
1251
1252 if isinstance(returns, _pd.DataFrame):1253 if len(returns.columns) > 1:
1254 if isinstance(strategy_colname, str):
1255 strategy_colname = list(returns.columns)
Consider merging collapsible if statements
672 strategy_title = kwargs.get("strategy_title", "Strategy")
673 active = kwargs.get("active_returns", "False")
674
675 if isinstance(returns, _pd.DataFrame): 676 if len(returns.columns) > 1 and isinstance(strategy_title, str):
677 strategy_title = list(returns.columns)
678
Consider merging collapsible if statements
523 strategy_title = kwargs.get("strategy_title", "Strategy")
524 active = kwargs.get("active_returns", "False")
525
526 if isinstance(returns, _pd.DataFrame): 527 if len(returns.columns) > 1 and isinstance(strategy_title, str):
528 strategy_title = list(returns.columns)
529
Consider merging collapsible if statements
93 returns = _utils._prepare_returns(returns)
94
95 strategy_title = kwargs.get("strategy_title", "Strategy")
96 if isinstance(returns, _pd.DataFrame): 97 if len(returns.columns) > 1 and isinstance(strategy_title, str):
98 strategy_title = list(returns.columns)
99
Consider merging collapsible if statements
670 color="gray",
671 )
672
673 if hline is not None: 674 if not isinstance(hline, _pd.Series):
675 if grayscale:
676 hlcolor = "black"
Consider merging collapsible if statements
339 # use a more precise date string for the x axis locations in the toolbar
340 # ax.fmt_xdata = _mdates.DateFormatter('%Y-%m-%d')
341
342 if hline is not None: 343 if not isinstance(hline, _pd.Series):
344 if grayscale:
345 hlcolor = "black"
Consider merging collapsible if statements
181 # rotate and align the tick labels so they look better
182 fig.autofmt_xdate()
183
184 if hline is not None: 185 if not isinstance(hline, _pd.Series):
186 if grayscale:
187 hlcolor = "gray"
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.