scipy/scipy — pull request #4001 by grlee77 (2014-09-17 22:24:32+00:00)
Title: ENH:  numerical precision in dirichlet

This is a numerical stability fix to `scipy.special.diric`

Two separate issues are addressed in this pull request:

1) For `diric(x, n)` with `x` very close to 2*pi, substantial oscillation occurs. There was currently a fix when x was an *exact* multiple of 2*pi. The proposed fix extends this to within a certain precision threshold around 2*pi. The optimal threshold to be used is up for debate, but the values proposed seem reasonable. The following notebook illustrates the issues prior to and after the proposed fix:

http://nbviewer.ipython.org/github/grlee77/notebooks_sandbox/blob/master/diric_bugfix.ipynb

2) Although the docstring says `n` should be an integer, this was not being enforced and n was actually converted to an array equal in size to `x`. I propose to return a ValueError if `n` is not a positive integer. The previous behavior returned an array that was `nan` for any locations where the input `n` was not a positive integer. This is also demonstrated in the notebook linked above. Is there any case where the old behavior allowing an arbitrary array of `n` values would be used?

Apologies in advance if this should have been two separate pull requests (I am still new to development on github).