{"record":{"id":"41ff5b7c43d08ef7","repo":"keras-team/keras","slug":"if-a-string-is-passed-to-window-it-must-be-one-41ff5b","errorCode":null,"errorMessage":"If a string is passed to `window`, it must be one of `\"hann\"`, `\"hamming\"`. Received: window={window}","messagePattern":"If a string is passed to `window`, it must be one of `\"hann\"`, `\"hamming\"`\\. Received: window=(.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/backend/tensorflow/math.py","lineNumber":193,"sourceCode":"\n\ndef stft(\n    x, sequence_length, sequence_stride, fft_length, window=\"hann\", center=True\n):\n    if standardize_dtype(x.dtype) not in {\"float32\", \"float64\"}:\n        raise TypeError(\n            \"Invalid input type. Expected `float32` or `float64`. \"\n            f\"Received: input type={x.dtype}\"\n        )\n    if fft_length < sequence_length:\n        raise ValueError(\n            \"`fft_length` must equal or larger than `sequence_length`. \"\n            f\"Received: sequence_length={sequence_length}, \"\n            f\"fft_length={fft_length}\"\n        )\n    if isinstance(window, str):\n        if window not in {\"hann\", \"hamming\"}:\n            raise ValueError(\n                \"If a string is passed to `window`, it must be one of \"\n                f'`\"hann\"`, `\"hamming\"`. Received: window={window}'\n            )\n    x = convert_to_tensor(x)\n\n    if center:\n        pad_width = [(0, 0) for _ in range(len(x.shape))]\n        pad_width[-1] = (fft_length // 2, fft_length // 2)\n        x = tf.pad(x, pad_width, mode=\"reflect\")\n\n    l_pad = (fft_length - sequence_length) // 2\n    r_pad = fft_length - sequence_length - l_pad\n\n    if window is not None:\n        if isinstance(window, str):\n            if window == \"hann\":\n                win_array = tf.signal.hann_window(\n                    sequence_length, periodic=True, dtype=x.dtype","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/tensorflow/math.py#L175-L211","documentation":"Error \"If a string is passed to `window`, it must be one of `\"hann\"`, `\"hamming\"`. Received: window={window}\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/backend/tensorflow/math.py:193 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}