{"record":{"id":"42b9343405592f1c","repo":"keras-team/keras","slug":"invalid-value-for-argument-method-expected-of-o-42b934","errorCode":null,"errorMessage":"Invalid value for argument `method`. Expected of one {SCALE_AND_TRANSLATE_METHODS}. Received: method={method}","messagePattern":"Invalid value for argument `method`\\. Expected of one (.+?)\\. Received: method=(.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/backend/numpy/ops/image.py","lineNumber":1189,"sourceCode":"\n    if need_squeeze:\n        transformed_images = np.squeeze(transformed_images, axis=0)\n    transformed_images = transformed_images.astype(input_dtype)\n\n    return transformed_images\n\n\ndef scale_and_translate(\n    images,\n    output_shape,\n    scale,\n    translation,\n    spatial_dims,\n    method,\n    antialias=True,\n):\n    if method not in SCALE_AND_TRANSLATE_METHODS:\n        raise ValueError(\n            \"Invalid value for argument `method`. Expected of one \"\n            f\"{SCALE_AND_TRANSLATE_METHODS}. Received: method={method}\"\n        )\n    if method in (\"linear\", \"bilinear\", \"trilinear\", \"triangle\"):\n        method = \"linear\"\n    elif method in (\"cubic\", \"bicubic\", \"tricubic\"):\n        method = \"cubic\"\n\n    images = convert_to_tensor(images)\n    scale = convert_to_tensor(scale)\n    translation = convert_to_tensor(translation)\n    kernel = _kernels[method]\n    dtype = backend.result_type(scale.dtype, translation.dtype)\n    scale = scale.astype(dtype)\n    translation = translation.astype(dtype)\n    return _scale_and_translate(\n        images,\n        output_shape,","sourceCodeStart":1171,"sourceCodeEnd":1207,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/numpy/ops/image.py#L1171-L1207","documentation":"Argument validation at the top of `scale_and_translate` (NumPy backend): the resampling `method` is checked against the SCALE_AND_TRANSLATE_METHODS set ('linear', 'bilinear', 'trilinear', 'cubic', 'bicubic', 'tricubic', 'lanczos3', 'lanczos5'). Any other string — wrong casing, a typo, or a method supported only by `resize` — fails the membership test and is rejected with the allowed set listed.","triggerScenarios":"Thrown at keras/src/backend/numpy/ops/image.py:1189 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass one of the supported method strings exactly as printed (e.g. 'bilinear', 'lanczos3')","Map resize-style names to their equivalents here ('bicubic' not 'cubic' if 'cubic' is rejected by your version's set)","Validate against the printed set and fall back to 'bilinear' for unknown user-supplied methods"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}