{"record":{"id":"046b538b436a6fb3","repo":"jax-ml/jax","slug":"unknown-resize-method-s","errorCode":null,"errorMessage":"Unknown resize method \"{s}\"","messagePattern":"Unknown resize method \"(.+?)\"","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/image/scale.py","lineNumber":275,"sourceCode":"\n  @staticmethod\n  def from_string(s: str):\n    if s == 'nearest':\n      return ResizeMethod.NEAREST\n    if s in ['linear', 'bilinear', 'trilinear', 'triangle']:\n      return ResizeMethod.LINEAR\n    elif s == 'lanczos3':\n      return ResizeMethod.LANCZOS3\n    elif s == 'lanczos5':\n      return ResizeMethod.LANCZOS5\n    elif s in ['cubic', 'bicubic', 'tricubic']:\n      return ResizeMethod.CUBIC\n    elif s in ['cubic-pytorch', 'bicubic-pytorch']:\n      return ResizeMethod.CUBIC_PYTORCH\n    elif s == 'area':\n      return ResizeMethod.AREA\n    else:\n      raise ValueError(f'Unknown resize method \"{s}\"')\n\n_kernels = {\n    ResizeMethod.LINEAR: (1, _fill_triangle_kernel),\n    ResizeMethod.LANCZOS3: (3, lambda x: _fill_lanczos_kernel(3., x)),\n    ResizeMethod.LANCZOS5: (5, lambda x: _fill_lanczos_kernel(5., x)),\n    ResizeMethod.CUBIC: (2, _fill_keys_cubic_kernel),\n    ResizeMethod.CUBIC_PYTORCH: (2, _fill_opencv_cubic_kernel),\n    ResizeMethod.AREA: (1, _area_kernel),\n}\n\n\n# scale and translation here are scalar elements of an np.array, what is the\n# correct type annotation?\ndef scale_and_translate(image, shape: core.Shape,\n                        spatial_dims: Sequence[int],\n                        scale, translation,\n                        method: str | ResizeMethod,\n                        antialias: bool = True,","sourceCodeStart":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/image/scale.py#L257-L293","documentation":"jax.image.scale's ResizeMethod.from_string parser only accepts a fixed set of method strings ('linear'/'bilinear', 'lanczos3', 'lanczos5', 'cubic'/'bicubic' and pytorch variants, 'nearest', 'area'). Any other string raises ValueError listing the unknown method.","triggerScenarios":"Passing method='bicubic_tf', 'trilinear', a typo like 'lanczos4', or an enum passed as a non-matching string to jax.image.resize / scale_and_translate.","commonSituations":"Porting code from torchvision/tf.image with method names that don't map to JAX's set; config files with stale method names after JAX upgrades renaming aliases.","solutions":["Use one of the supported strings or the ResizeMethod enum members directly (e.g. ResizeMethod.CUBIC)","Validate/whitelist the string at config-load time against the known set","Check the installed JAX version's supported list if using newer aliases"],"exampleFix":"# before\nimg2 = jax.image.resize(img, (64, 64), method='bicubic_tf')\n# after\nimg2 = jax.image.resize(img, (64, 64), method='bicubic')\n# or method=jax._src.image.scale.ResizeMethod.CUBIC","handlingStrategy":"validation","validationCode":"VALID = {'linear','bilinear','lanczos3','lanczos5','cubic','bicubic','cubic-pytorch','bicubic-pytorch','nearest','area'}\nif isinstance(method, str):\n    assert method in VALID, f'method must be one of {VALID}'\njax.image.resize(img, shape, method=method)","typeGuard":"def is_valid_resize_method(s: str) -> bool:\n    return s in {'linear','bilinear','lanczos3','lanczos5','cubic','bicubic','cubic-pytorch','bicubic-pytorch','nearest','area'}","tryCatchPattern":"try:\n    jax.image.resize(img, shape, method=m)\nexcept ValueError as e:\n    if 'Unknown resize method' in str(e):\n        m = 'cubic'  # safe fallback\n        jax.image.resize(img, shape, method=m)","preventionTips":["Centralize resize method names in config constants","Pass the ResizeMethod enum instead of strings"],"tags":["jax","image-resize","invalid-argument"],"backgroundTag":"unsupported-resize-method-string","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}