{"record":{"id":"0881457b8d8f93f4","repo":"jax-ml/jax","slug":"x-dtype-is-not-supported-see-docstring-for-sup","errorCode":null,"errorMessage":"x.dtype={} is not supported, see docstring for supported types.","messagePattern":"x\\.dtype=(.+?) is not supported, see docstring for supported types\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"jax/_src/scipy/special.py","lineNumber":1466,"sourceCode":"    \\mathrm{ndtr}(x) =&\n      \\ \\frac{1}{\\sqrt{2 \\pi}}\\int_{-\\infty}^{x} e^{-\\frac{1}{2}t^2} \\mathrm{d}t \\\\\n    =&\\ \\frac{1}{2} (1 + \\mathrm{erf}(\\frac{x}{\\sqrt{2}})) \\\\\n    =&\\ \\frac{1}{2} \\mathrm{erfc}(-\\frac{x}{\\sqrt{2}})\n    \\end{align}\n\n  Args:\n    x: An array of type `float32`, `float64`.\n\n  Returns:\n    An array with `dtype=x.dtype`.\n\n  Raises:\n    TypeError: if `x` is not floating-type.\n  \"\"\"\n  x = jnp.asarray(x)\n  dtype = lax.dtype(x)\n  if dtype not in (np.float32, np.float64):\n    raise TypeError(\n        \"x.dtype={} is not supported, see docstring for supported types.\"\n        .format(dtype))\n  return _ndtr(x)\n\n\ndef ndtri(p: ArrayLike) -> Array:\n  r\"\"\"The inverse of the CDF of the Normal distribution function.\n\n  JAX implementation of :obj:`scipy.special.ndtri`.\n\n  Returns `x` such that the area under the PDF from :math:`-\\infty` to `x` is equal\n  to `p`.\n\n  A piece-wise rational approximation is done for the function.\n  This is based on the implementation in netlib.\n\n  Args:\n    p: an array of type `float32`, `float64`.","sourceCodeStart":1448,"sourceCodeEnd":1484,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/scipy/special.py#L1448-L1484","documentation":"jax.scipy.special.ndtr (standard normal CDF) only accepts float32 or float64 arrays. After asarray, any other dtype (int, complex, bfloat16, float16) raises TypeError pointing at the docstring's supported types.","triggerScenarios":"Calling ndtr on integer arrays (ndtr(jnp.arange(3))), bfloat16/float16 tensors from TPUs or mixed-precision training, or complex inputs.","commonSituations":"Passing integer-valued data (counts, bins) into a Gaussian CDF; half-precision model weights under jit with x64 disabled; assuming automatic casting like NumPy's special functions.","solutions":["Cast to float: ndtr(x.astype(jnp.float32)) or jnp.asarray(x, jnp.float64)","Use promote_args_inexact-style casting upstream so tensors entering statistical functions are already float32/64","For bfloat16 pipelines, keep ndtr in float32 and cast back"],"exampleFix":"// before\njax.scipy.special.ndtr(jnp.array([0, 1, 2]))  # int32\n// after\njax.scipy.special.ndtr(jnp.array([0, 1, 2], dtype=jnp.float32))","handlingStrategy":"validation","validationCode":"x = jnp.asarray(x)\nif x.dtype not in (jnp.float32, jnp.float64):\n    x = x.astype(jnp.float32)\nndtr(x)","typeGuard":"def is_f32_f64(x):\n    return jnp.dtype(x) in (np.float32, np.float64)","tryCatchPattern":null,"preventionTips":["Always cast inputs to statistical functions to float32/64 at pipeline boundaries","Avoid bf16/fp16 tensors reaching special functions in mixed-precision training"],"tags":["jax","scipy-special","normal-cdf","dtype-validation"],"backgroundTag":"unsupported-input-dtype","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}