code: def test_calc_stats(df):
      # test twelve_month_win_perc divide by zero
      prices = df.C["2010-10-01":"2011-08-01"]
      stats = ffn.calc_stats(prices).stats
      assert pd.isnull(stats["twelve_month_win_perc"])
      prices = df.C["2009-10-01":"2011-08-01"]
      stats = ffn.calc_stats(prices).stats
      assert not pd.isnull(stats["twelve_month_win_perc"])
  
      # test yearly_sharpe divide by zero
      prices = df.C["2009-01-01":"2012-01-01"]
      stats = ffn.calc_stats(prices).stats
      assert "yearly_sharpe" in stats.index
  
      prices[prices > 0.0] = 1.0
      # throws warnings
      stats = ffn.calc_stats(prices).stats
      assert pd.isnull(stats["yearly_sharpe"])
  
imports: import ffn
  import pandas
  import numpy
  from pytest import fixture
  from numpy.testing import assert_almost_equal
label_desc: Use image node_id 36 for calling a global function with example usage: test_calc_stats(df) without return types