{"record":{"id":"61eddf5b3f6c3e63","repo":"jax-ml/jax","slug":"unrecognized-kind-expected-one-of-list-dtype","errorCode":null,"errorMessage":"Unrecognized {kind=} expected one of {list(_dtype_kinds.keys())}, or a compatible input for jnp.dtype()","messagePattern":"Unrecognized (.+?) expected one of (.+?), or a compatible input for jnp\\.dtype\\(\\)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"jax/_src/dtypes.py","lineNumber":672,"sourceCode":"      If ``kind`` is a tuple, then return True if dtype matches any entry of the tuple.\n\n  Returns:\n    True or False\n  \"\"\"\n  the_dtype = np.dtype(dtype)\n  kind_tuple: tuple[str | DTypeLike, ...] = (\n    kind if isinstance(kind, tuple) else (kind,)\n  )\n  options: set[DType] = set()\n  for kind in kind_tuple:\n    if isinstance(kind, str) and kind in _dtype_kinds:\n      options.update(_dtype_kinds[kind])\n      continue\n    try:\n      _dtype = np.dtype(kind)\n    except TypeError as e:\n      if isinstance(kind, str):\n        raise ValueError(\n          f\"Unrecognized {kind=} expected one of {list(_dtype_kinds.keys())}, \"\n          \"or a compatible input for jnp.dtype()\")\n      raise TypeError(\n        f\"Expected kind to be a dtype, string, or tuple; got {kind=}\"\n      ) from e\n    options.add(_dtype)\n  return the_dtype in options\n\n\ndef _jax_type(dtype: DType, weak_type: bool) -> JAXType:\n  \"\"\"Return the jax type for a dtype and weak type.\"\"\"\n  if weak_type:\n    if dtype == bool:\n      return dtype\n    if dtype in _custom_float_dtypes:\n      return float\n    return type(dtype.type(0).item())\n  return dtype","sourceCodeStart":654,"sourceCodeEnd":690,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/dtypes.py#L654-L690","documentation":"jax.dtypes.isdtype implements the Array API: kind may be a recognized kind string ('bool','signed integer',...), a dtype-like, or tuples thereof. A string that is neither a known kind nor constructible by np.dtype raises ValueError; non-string non-dtype inputs raise TypeError.","triggerScenarios":"isdtype(dtype, kind='int') — 'int' is not a valid kind (valid: 'signed integer', 'unsigned integer', 'real floating', etc.); or passing an arbitrary object as kind.","commonSituations":"Users abbreviating kind names ('float' instead of 'real floating', 'int' instead of 'signed integer') when porting numpy-style checks to the Array API.","solutions":["Use exact Array API kind strings: 'bool', 'signed integer', 'unsigned integer', 'real floating', 'complex floating', 'numeric', 'integral'","For simple checks prefer jnp.issubdtype(dtype, jnp.integer) / np.dtype comparisons","Pass dtype-like objects (np.int32, 'int32') instead of ambiguous short names"],"exampleFix":"# before\nisdtype(dtype, kind='int')\n\n# after\nisdtype(dtype, kind='signed integer')  # or isdtype(dtype, np.int64)","handlingStrategy":"type-guard","validationCode":"valid_kinds = {'bool','signed integer','unsigned integer','integral','real floating','complex floating','numeric'}\nif isinstance(kind, str) and kind not in valid_kinds:\n    kind = {'int': 'signed integer', 'uint': 'unsigned integer',\n            'float': 'real floating', 'complex': 'complex floating'}.get(kind, kind)","typeGuard":"def is_valid_kind(k) -> bool:\n    valid = {'bool','signed integer','unsigned integer','integral','real floating','complex floating','numeric'}\n    return (isinstance(k, tuple) and all(is_valid_kind(x) for x in k)) or k in valid or _is_dtype_like(k)","tryCatchPattern":"try:\n    isdtype(dtype, kind)\nexcept ValueError:\n    isdtype(dtype, 'signed integer')  # mapped kind","preventionTips":["Use exact Array API kind strings","Prefer jnp.issubdtype for numpy-style checks"],"tags":["jax","dtype","array-api","validation"],"backgroundTag":"invalid-dtype","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}