Ejemplo n.º 1
0
    def columnUncertainty(self):
        """Returns uncertainty (Shannon's entropy) for each column in profile

        Uncertainty is returned in BITS (not in NATS).
        """
        if not self.Data:
            return array([])
        try:
            return column_uncertainty(self.Data)
        except ValueError:
            raise ProfileError,\
            "Profile has to be two dimensional to calculate columnUncertainty"
Ejemplo n.º 2
0
 def test_col_uncertainty(self):
     """column_uncertainty: should handle pos/neg/zero/empty arrays
     """
     b = array([[.25,.2,.45,.25,1],[.25,.2,.45,0,0],[.25,.3,.05,.75,0],\
         [.25,.3,.05,0,0]])
     self.assertFloatEqual(column_uncertainty(b),[2,1.97,1.47,0.81,0],1e-3)
     #one-dimensional array
     self.assertRaises(ValueError, column_uncertainty,\
         array([.25,.25,.25,.25]))
     #zeros
     self.assertEqual(column_uncertainty(array([[0,0]])),array([0,0]))
     #empty 2D array
     self.assertEqual(column_uncertainty(array([[]])),array([]))
     self.assertEqual(column_uncertainty(array([[],[]])),array([]))
     #negative number
     self.assertNotEqual(column_uncertainty(array([[-2]])),\
         column_uncertainty(array([[-2]])))