code: def test_removes_infinite_values():
      data = mtcars.copy()
      data.loc[[0, 5], "wt"] = [np.inf, -np.inf]
      p = ggplot(data, aes(x="wt")) + geom_bar()
  
      with pytest.warns(PlotnineWarning) as record:
          p._build()
  
      def removed_2_row_with_infinites(record):
          for item in record:
              msg = str(item.message).lower()
              if "2 rows" in msg and "non-finite" in msg:
                  return True
          return False
  
      assert removed_2_row_with_infinites(record)
  
file_path: plotnine/tests/test_stat.py
imports: import numpy
  import pytest
  from plotnine import aes, geom_bar, ggplot
  from plotnine.data import mtcars
  from plotnine.exceptions import PlotnineError, PlotnineWarning
  from plotnine.geoms.geom import geom
  from plotnine.stats.stat import stat
label_desc: Use image node_id 4 for calling a global function with example usage: test_removes_infinite_values() and returns: False, True