jbkinney / mavenn

MAVE-NN: genotype-phenotype maps from multiplex assays of variant effect
MIT License
24 stars 5 forks source link

bug in ProfileInfo method nsb (python 3 only) #4

Closed atareen closed 4 years ago

atareen commented 6 years ago

The following code is throwing an mpmath error when run in python 3. The code is being called from ProfileInfo with method ='nsb' Part of the error message is : TypeError: cannot create mpf from 6 Note that I have already tried passing in floating point arguments to quadgl.

def S(x, N, K): 
  """
  Return the estimated entropy. x is a vector of counts, nxkx is the histogram 
  of the input histogram constructed by make_nxkx. N is the total number of 
  elements, and K is the degree of freedom.

  >>> from numpy import array
  >>> nTest = array([4, 2, 3, 0, 2, 4, 0, 0, 2])
  >>> K = 9  # which is actually equal to nTest.size.
  >>> S(make_nxkx(nTest, K), nTest.sum(), K)
  1.9406467285026877476
  """
  nxkx = make_nxkx(x,K)
  mp.dps = DPS
  mp.pretty = True

  f = lambda w: _Si(w, nxkx, N, K)
  g = lambda w: _measure(w, nxkx, N, K)

  return np.log2(np.exp(1))*quadgl(f, [0, 1])/quadgl(g, [0, 1])