Return NaN in C implementations of SciPy Ops #224
Labels
backend compatibility
Issues relating to compatibility with backends called by this library
bug
Something isn't working
C-backend
help wanted
Extra attention is needed
This is related to pymc-devs/pymc#4340
I am trying to use the
GammaIncc
Op, which makes use of the C code functionGammaQ
, which begins with an assertion for the two parameters. This is problematic when using the tensor version of the scalar op (via @_scal_elemwise), as I don't see how to gracefully avoid the assertion error.To make this concrete, gammaincc is being used in the logcdf method of the pymc3 InverseGamma distribution. It is wrapped inside a
bound
which seems to lazy evaluate when working with scalars, but not with tensors. This allows it to gracefully return -np.inf when evaluated with invalid scalar arguments, but not when using a tensor/array.The
scipy.special.gammaincc(x, k)
counterpart does not have this issue.Does anyone know a workaround to avoid this issue when working with tensors?
https://github.com/pymc-devs/pymc3/blob/043129243436b875a9ab18180549491c4678b7c6/pymc3/distributions/continuous.py#L2654-L2659
https://github.com/pymc-devs/Theano-PyMC/blob/2601e7acf8442422cab19db5bd029a5581f0bdec/theano/tensor/basic.py#L2529-L2531
https://github.com/pymc-devs/Theano-PyMC/blob/819122e66bcd089b2a3f472542800feead0bf755/theano/scalar/basic_scipy.py#L598-L639
https://github.com/pymc-devs/Theano-PyMC/blob/819122e66bcd089b2a3f472542800feead0bf755/theano/scalar/c_code/gamma.c#L227-L233
The text was updated successfully, but these errors were encountered: