Пример #1
0
 def test_enspie(self):
     """Test that ENS_pie is correctly calculated."""
     #example1 - totally even community shoudl have ENS_pie=number of species
     c = array([1,1,1,1,1,1])
     self.assertFloatEqual(enspie(c), 6)
     c = array([13,13,13,13])
     self.assertFloatEqual(enspie(c), 4)
     #example2 - hand calculated
     c = array([1, 41, 0, 0, 12, 13]).astype(float)
     exp = 1./((c/c.sum())**2).sum()
     self.assertFloatEqual(enspie(c), exp)
     #example3 using dominance
     exp = 1./dominance(c)
     self.assertFloatEqual(enspie(c), exp)
Пример #2
0
 def test_simpson_reciprocal(self):
     """simpson_reciprocal should match 1/D  results"""
     c = array([1,0,2,5,2])
     self.assertFloatEqual(simpson_reciprocal(c), 1./dominance(c))
Пример #3
0
 def test_dominance(self):
     """dominance should match hand-calculated values"""
     c = array([1,0,2,5,2])
     self.assertFloatEqual(dominance(c), .34)
     d = array([5])
     self.assertEqual(dominance(d), 1)
Пример #4
0
 def test_simpson_reciprocal(self):
     """simpson_reciprocal should match 1/D  results"""
     c = array([1,0,2,5,2])
     self.assertFloatEqual(simpson_reciprocal(c), 1./dominance(c))
Пример #5
0
 def test_dominance(self):
     """dominance should match hand-calculated values"""
     c = array([1,0,2,5,2])
     self.assertFloatEqual(dominance(c), .34)
     d = array([5])
     self.assertEqual(dominance(d), 1)