code: def testAvgGainLoss(self):
      # We divide by 2 because N samples yield N-1 averages.
  
      # Gain only
      avgGain, avgLoss = rsi.avg_gain_loss([1, 2, 3], 0, 3)
      self.assertTrue(avgGain == 2 / float(2))
      self.assertTrue(avgLoss == 0)
  
      # Loss only
      avgGain, avgLoss = rsi.avg_gain_loss([3, 2, 1], 0, 3)
      self.assertTrue(avgGain == 0)
      self.assertTrue(avgLoss == 2 / float(2))
  
      # Gain and Loss equal
      avgGain, avgLoss = rsi.avg_gain_loss([1, 0, 1], 0, 3)
      self.assertTrue(avgGain == 1 / float(2))
      self.assertTrue(avgLoss == 1 / float(2))
  
      # Gain and Loss different
      avgGain, avgLoss = rsi.avg_gain_loss([1, 3, 2], 0, 3)
      self.assertTrue(avgGain == 2 / float(2))
      self.assertTrue(avgLoss == 1 / float(2))
  
      # Error
      self.assertEqual(rsi.avg_gain_loss([1, 1.5, 2], 0, 1), None)
      self.assertEqual(rsi.avg_gain_loss([1, 1.5, 2], 1, 2), None)
      with self.assertRaises(IndexError):
          rsi.avg_gain_loss([1, 1.5, 2], 2, 4)
  
file_path: pyalgotrade/testcases/technical_rsi_test.py
imports: from .None import common
  from pyalgotrade.technical import rsi
  from pyalgotrade import dataseries
label_desc: Use image node_id 1 for calling the TestCase obj's underlying member method code with example usage: obj.testAvgGainLoss() without return types