{"record":{"id":"ea5161e96375da80","repo":"jax-ml/jax","slug":"dtype-argument-to-logistic-must-be-a-float-dtype","errorCode":null,"errorMessage":"dtype argument to `logistic` must be a float dtype, got {dtype}","messagePattern":"dtype argument to `logistic` must be a float dtype, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/random/core.py","lineNumber":2517,"sourceCode":"    dtype: optional, a float dtype for the returned values (default float64 if\n      jax_enable_x64 is true, otherwise float32).\n    out_sharding: Optional. Specifies how the output array should be sharded\n      across devices in multi-device computation. Can be a\n      :class:`~jax.sharding.NamedSharding`, a :class:`~jax.sharding.PartitionSpec`\n      (``P``), or ``None`` (default). When specified, the output will be sharded\n      according to the given sharding specification. Primarily used in explicit\n      sharding mode.\n      See the `explicit sharding tutorial <https://docs.jax.dev/en/latest/parallel.html>`_\n      for more details.\n\n  Returns:\n    A random array with the specified shape and dtype.\n  \"\"\"\n  key, _ = _check_prng_key(\"logistic\", key)\n  dtype = dtypes.check_and_canonicalize_user_dtype(\n      float if dtype is None else dtype)\n  if not dtypes.issubdtype(dtype, np.floating):\n    raise ValueError(f\"dtype argument to `logistic` must be a float \"\n                     f\"dtype, got {dtype}\")\n  shape = core.canonicalize_shape(shape)\n  out_sharding = canonicalize_sharding_for_samplers(out_sharding, \"logistic\", shape)\n  return maybe_auto_axes(_logistic, out_sharding,\n                         shape=shape, dtype=dtype)(key)\n\n@jit(static_argnums=(1, 2))\ndef _logistic(key, shape, dtype):\n  _check_shape(\"logistic\", shape)\n  x = uniform(key, shape, dtype, minval=dtypes.finfo(dtype).tiny, maxval=1.)\n  return lax.sub(lax.log(x), lax.log1p(lax.neg(x)))\n\n\ndef pareto(key: ArrayLike,\n           b: RealArray,\n           shape: Shape | None = None,\n           dtype: DTypeLikeFloat | None = None,\n           *,","sourceCodeStart":2499,"sourceCodeEnd":2535,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/random/core.py#L2499-L2535","documentation":"jax.random.logistic requires a floating-point dtype because the logistic sampler computes log(u/(1-u)) in float arithmetic. Integer or complex dtypes raise ValueError before the jit-compiled sampler runs.","triggerScenarios":"jax.random.logistic(key, shape, dtype=jnp.int32) or any non-floating dtype argument.","commonSituations":"Configured dtype reuse across samplers; assuming default dtype is int for distribution samplers; typos like passing jnp.int64 during experimentation.","solutions":["Use jnp.float32/jnp.float64 or omit dtype.","Validate dtypes against np.floating in any dtype-configurable pipeline."],"exampleFix":"// before\nx = jax.random.logistic(key, (100,), dtype=jnp.int32)\n\n// after\nx = jax.random.logistic(key, (100,), dtype=jnp.float32)","handlingStrategy":"type-guard","validationCode":"from jax._src import dtypes\nassert dtypes.issubdtype(dtypes.check_and_canonicalize_user_dtype(dtype or float), np.floating)","typeGuard":"def is_float_dtype(dtype) -> bool:\n    from jax._src import dtypes\n    import numpy as np\n    return dtypes.issubdtype(dtypes.check_and_canonicalize_user_dtype(dtype or float), np.floating)","tryCatchPattern":null,"preventionTips":["Omit dtype unless a specific float width is needed."],"tags":["jax","random","logistic","dtype","input-validation"],"backgroundTag":"invalid-dtype-argument","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}