{"record":{"id":"95dd7ab3b33ed5ee","repo":"jax-ml/jax","slug":"dtype-argument-to-pareto-must-be-a-float-dtype","errorCode":null,"errorMessage":"dtype argument to `pareto` must be a float dtype, got {dtype}","messagePattern":"dtype argument to `pareto` must be a float dtype, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/random/core.py","lineNumber":2572,"sourceCode":"      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 dtype and with shape given by ``shape`` if\n    ``shape`` is not None, or else by ``b.shape``.\n  \"\"\"\n  key, _ = _check_prng_key(\"pareto\", 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 `pareto` must be a float \"\n                     f\"dtype, got {dtype}\")\n  shape = _check_broadcast_shapes(\"pareto\", shape, b)\n  _check_all_safe_to_cast(\"pareto\", dtype, b)\n  out_sharding = canonicalize_sharding_for_samplers(out_sharding, \"pareto\", shape)\n  return maybe_auto_axes(_pareto, out_sharding,\n                         shape=shape, dtype=dtype)(key, b)\n\n@jit(static_argnums=(2, 3))\ndef _pareto(key, b, shape, dtype) -> Array:\n  b = lax.convert_element_type(b, dtype)\n  e = exponential(key, shape, dtype)\n  return lax.exp(e / b)\n\n\ndef t(key: ArrayLike,\n      df: RealArray,\n      shape: Shape | None = None,\n      dtype: DTypeLikeFloat | None = None,","sourceCodeStart":2554,"sourceCodeEnd":2590,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/random/core.py#L2554-L2590","documentation":"jax.random.pareto requires a floating-point output dtype; the sampler builds on jax.random.exponential (itself float-only) and then applies a power transform. Integer or complex dtypes raise ValueError. The dtype must also be safe to cast b to, checked separately by _check_all_safe_to_cast.","triggerScenarios":"jax.random.pareto(key, b, dtype=jnp.int32) or any dtype where dtypes.issubdtype(dtype, np.floating) is False.","commonSituations":"Heavy-tail noise generation configs with a single shared dtype; porting NumPy pareto code that has no dtype parameter; combining with int-based samplers in the same module.","solutions":["Pass jnp.float32/jnp.float64 or omit dtype.","Also ensure the shape b broadcasts (shape is checked via _check_broadcast_shapes) and b can be safely cast to dtype.","Validate configurable dtypes against np.floating before calling."],"exampleFix":"// before\nx = jax.random.pareto(key, b, dtype=jnp.int32)\n\n// after\nx = jax.random.pareto(key, b, 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":["Also keep b castable to the chosen dtype to pass the safe-cast check."],"tags":["jax","random","pareto","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"}