if
statement have similar implementation PTC-W0051110 axes[1].set_ylabel('Drawdown', fontname=fontname,
111 fontweight='bold', fontsize=12)
112 axes[1].set_yticks(_np.arange(-ddmin, 0, step=ddmin_ticks))
113 axes[1].plot(dd, color=colors[2], lw=1 if grayscale else 1, zorder=1)114 axes[1].axhline(0, color='silver', lw=1, zorder=0)
115 if not grayscale:
116 axes[1].fill_between(dd.index, 0, dd, color=colors[2], alpha=.1)
For the highlighted if
statements, all the elif
/ else
branches have the same body as if
.
It is recommended to refactor this snippet.
If the if-chain is performing the same action in every case, it shouldn't be used there at all.
if b == 0:
do_something()
elif b == 1:
do_something()
else:
do_something()
b = 4 if a > 12 else 4
# If this is was a copy-paste error, review and update the snippet
if b == 0:
do_something()
elif b == 1:
do_something_else()
else:
do_other_thing()
b = -4 if a > 12 else 4
# OR
# Refactor the code to not use the if-chain at all.
do_something()
b = 4