docstr: st.pyplot should clear the global figure if `clear_figure` is
  True *or* None.
docstr_tok: ["st.pyplot","should","clear","the","global","figure","if","`","clear_figure","`","is","True","*","or","*","None","."]
code: def test_st_pyplot_clear_global_figure(
      self, _, clear_figure: Optional[bool]
  ):
      """st.pyplot should clear the global figure if `clear_figure` is
      True *or* None.
      """
      plt.hist(np.random.normal(1, 1, size=100), bins=20)
      with patch.object(
          plt, "clf", wraps=plt.clf, autospec=True
      ) as plt_clf:
          st.pyplot(clear_figure=clear_figure)
  
          if clear_figure in (True, None):
              plt_clf.assert_called_once()
          else:
              plt_clf.assert_not_called()
  
file_path: streamlit/lib/tests/streamlit/elements/pyplot_test.py
imports: from typing import Optional
  from unittest.mock import patch
  import matplotlib
  import matplotlib.pyplot
  import numpy
  from parameterized import parameterized
  import streamlit
  from streamlit.elements import image
  from streamlit.web.server.server import MEDIA_ENDPOINT
  from tests.delta_generator_test_case import DeltaGeneratorTestCase
label_desc: Use image node_id 4 for calling the PyplotTest obj's underlying member method code with example usage: obj.test_st_pyplot_clear_global_figure(_, clear_figure) without return types