A problem with stats.fisher_exact was reported on stackoverflow:
The culprit appears to be this line:
I assume that np.max(pexact, pmode) should be np.maximum(pexact, pmode).
As it is now, pmode is being passed to np.max() as its axis argument. Usually pmode is less than 1, so the axis value is truncated to 0 and an error is not generated. For the special case reported in the Stack Overflow question, stats.fisher_exact([[1,2],[9,84419233]]), pmode is 1.00000001738, so an error is raised.
the change to np.maximum looks correct to me, but I also don't know the algorithm.
pmode shouldn't be really above one since it's a probability.
I don't think this bug could have produced numbers that are much wrong, since the condition only holds if pexact and pmode are almost the same.
I also don't know the algorithm. But will happily prepare a PR if you think this doesn't need further investigation.
Why the abs in the denominator of https://github.com/scipy/scipy/blob/master/scipy/stats/stats.py#L2583? Both pmode and pexact should be positive.
Why the float in the numerator? Both pmode and pexact are results of hypergeom.pmf, so should both be float, so their difference should be float.
@rgommers: Since this seems to be "your" code, can you comment?
IIRC that was due to a bug in stats.hypergeom, where p-value could be negative. Fixed in 0.14.0, so abs can be removed from denominator.
max --> maximum fix looks right to me.
`float: don't remember. Could be useless, or also a bug fix. Anyway, looks to me like it can be removed now.
BUG: fix use of np.max in stats.fisher_exact