{"record":{"id":"637859cd5eb73e0f","repo":"jax-ml/jax","slug":"invalid-argument-method-expected-one-of-list","errorCode":null,"errorMessage":"invalid argument {method=}, expected one of {list(self.valid_methods)}","messagePattern":"invalid argument (.+?), expected one of (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/numpy/hijax.py","lineNumber":88,"sourceCode":"          f\"batch_dims={batch_dims} must be in range [0, {sorted_arr_aval.ndim})\"\n      )\n    dimension = operator.index(dimension)\n    if not batch_dims <= dimension < sorted_arr_aval.ndim:\n      raise ValueError(\n          f\"dimension={dimension} must be in range [{batch_dims},\"\n          f\" {sorted_arr_aval.ndim})\"\n      )\n    if sorted_arr_aval.dtype != query_aval.dtype:\n      raise ValueError(\n          \"dtypes of sorted_arr and query must match; got \"\n          f\"{sorted_arr_aval.dtype} and {query_aval.dtype}\"\n      )\n    if side not in [\"left\", \"right\"]:\n      raise ValueError(\n          f\"invalid argument side={side!r}, expected 'left' or 'right'\"\n      )\n    if method not in self.valid_methods:\n      raise ValueError(\n          f\"invalid argument {method=}, expected one of {list(self.valid_methods)}\"\n      )\n    if sorted_arr_aval.shape[:batch_dims] != query_aval.shape[:batch_dims]:\n      raise ValueError(\n          \"batch dimension sizes must match; got\"\n          f\" {sorted_arr_aval.shape[:batch_dims]} != {query_aval.shape[:batch_dims]}\"\n      )\n    if not dtypes.issubdtype(out_dtype, np.integer):\n      raise ValueError(f\"out_dtype should be an integer type; got {out_dtype}\")\n    # Attempt this here to catch overflow errors early.\n    out_dtype.type(sorted_arr_aval.shape[dimension])\n    self.in_avals = (sorted_arr_aval, query_aval)\n    self.out_aval = core.typeof(api.eval_shape(\n      functools.partial(_searchsorted_impl,\n        dimension=dimension, batch_dims=batch_dims, side=side,\n        dtype=out_dtype, method=method),\n        sorted_arr_aval, query_aval))\n    self.params = dict(","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/numpy/hijax.py#L70-L106","documentation":"Raised by the SearchSorted HiJAX primitive when the method argument is not one of ('compare_all', 'scan', 'scan_unrolled', 'sort'). method selects the lower-level implementation strategy for the search (e.g. binary scan, full sort, or pairwise compare) used inside the primitive.","triggerScenarios":"Calling searchsorted with method='binary' (the intuitive but invalid guess), method='scans', or any string outside the four valid methods listed in the error message.","commonSituations":"Assuming numpy-compatible parameter names; copy-pasting method names from a different JAX version or a different search API.","solutions":["Use one of the methods printed in the error: 'compare_all', 'scan', 'scan_unrolled', or 'sort'","Leave method at its default rather than guessing names"],"exampleFix":"# before\nidx = jax_hijax_searchsorted(a, v, method='binary')\n# after\nidx = jax_hijax_searchsorted(a, v, method='scan')","handlingStrategy":"validation","validationCode":"VALID = ('compare_all', 'scan', 'scan_unrolled', 'sort')\nassert method in VALID, f'{method=} not in {VALID}'","typeGuard":"def valid_method(m: str) -> bool:\n    return m in ('compare_all', 'scan', 'scan_unrolled', 'sort')","tryCatchPattern":null,"preventionTips":["Leave method at default unless benchmarking","Treat method names as an enum; add a unit test enumerating valid values"],"tags":["jax","searchsorted","argument-validation"],"backgroundTag":"invalid-enum-argument","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}