{"record":{"id":"8eaf5f25296e302d","repo":"jax-ml/jax","slug":"jnp-poch-does-not-support-complex-valued-inputs","errorCode":null,"errorMessage":"jnp.poch does not support complex-valued inputs.","messagePattern":"jnp\\.poch does not support complex-valued inputs\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/scipy/special.py","lineNumber":3174,"sourceCode":"  .. math::\n\n     \\mathrm{poch}(z, m) = (z)_m = \\frac{\\Gamma(z + m)}{\\Gamma(z)}\n\n  where :math:`\\Gamma(z)` is the :func:`~jax.scipy.special.gamma` function.\n\n  Args:\n    z: arraylike, real-valued\n    m: arraylike, real-valued\n\n  Returns:\n    array of Pochhammer values.\n\n  Notes:\n    The JAX version supports only real-valued inputs.\n  \"\"\"\n  z, m = promote_args_inexact(\"poch\", z, m)\n  if dtypes.issubdtype(z.dtype, np.complexfloating):\n    raise ValueError(\"jnp.poch does not support complex-valued inputs.\")\n\n  return jnp.where(m == 0., jnp.array(1, dtype=z.dtype), gamma(z + m) / gamma(z))\n\n\ndef _poch_z_derivative(z, m):\n  \"\"\"\n  Defined in :\n  https://functions.wolfram.com/GammaBetaErf/Pochhammer/20/01/01/\n  \"\"\"\n\n  return (digamma(z + m) - digamma(z)) * poch(z, m)\n\n\ndef _poch_m_derivative(z, m):\n  \"\"\"\n  Defined in :\n  https://functions.wolfram.com/GammaBetaErf/Pochhammer/20/01/02/\n  \"\"\"","sourceCodeStart":3156,"sourceCodeEnd":3192,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/scipy/special.py#L3156-L3192","documentation":"jax.scipy.special.poch only implements real-valued inputs. After promoting arguments with promote_args_inexact, the code explicitly checks dtypes.issubdtype(z.dtype, np.complexfloating) and raises, unlike scipy.special.poch which supports complex z and m.","triggerScenarios":"Calling jax.scipy.special.poch(z, m) where either argument is complex (e.g. complex128) or a mix like float + complex that promotes to a complex dtype.","commonSituations":"Porting scipy code that uses complex arguments; feeding complex-valued parameters from physics/engineering models into the JAX implementation.","solutions":["Split z into real and imaginary parts and compute via gamma: poch = gamma(z+m)/gamma(z) using an implementation that supports complex, or keep inputs real.","Use scipy.special.poch on the host (CPU) if complex support is required.","Check dtypes before calling and cast/downcast if the complex part is zero."],"exampleFix":"// before\njax.scipy.special.poch(2+1j, 3)\n\n// after\nimport scipy.special\nscipy.special.poch(2+1j, 3)  # complex path handled on host","handlingStrategy":"type-guard","validationCode":"assert not jnp.issubdtype(jnp.result_type(z, m), jnp.complexfloating), \"poch requires real inputs\"","typeGuard":"def is_real_poch_args(z, m) -> bool:\n    return not jnp.issubdtype(jnp.result_type(z, m), jnp.complexfloating)","tryCatchPattern":null,"preventionTips":["Keep special-function inputs real in jax pipelines.","Route complex special functions to scipy/mpmath on host."],"tags":["jax","scipy","poch","complex-dtype","unsupported-operation"],"backgroundTag":"jax-complex-unsupported","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}