popgenmethods / momi2

Infer demographic history with the Moran model
GNU General Public License v3.0
47 stars 11 forks source link

Bug in fit_within_pop_diversity() #62

Closed trevorcousins closed 1 year ago

trevorcousins commented 1 year ago

I have defined a model and given it parameters (no inference).

If I try to estimate the mutation rate with: model.fit_within_pop_diversity() Then I get the following error: numpy.core._exceptions._UFuncNoLoopError: ufunc 'subtract' did not contain a loop with signature matching types (dtype('float64'), dtype('<U8')) -> None I dug into this - for line 454 in .../momi/sfs_stats.py we have two variables, self.observed and self.expected . self.observed is a numpy.float64 but self.expected is a str. Perhaps I gave the model my variables in an unorthodox way.

Of course to fix this all I had to do was: change line 454 from (self.observed - self.expected) / self.sd to (self.observed - float(self.expected)) / self.sd

trevorcousins commented 1 year ago

My mistake. Indeed I was inputting mu as a string which creates this error. I input it like this because when bootstrapping, I save the inferred parameters to a dict, which loads as a string by default.