Repository: scipy/scipy
Pull request: ENH: Warn about missing boundary when NOLA condition failed in ISTFT …
Warn about missing boundary when NOLA condition failed. #17885

#### Reference issue
closes: #17885 

#### What does this implement/fix?
Add additional information to the warning message.

Problem statement:
ENH: signal.istft gives NOLA conditional failed warning but signal.check_NOLA functions tells me the constraint is satisfies
### Is your feature request related to a problem? Please describe.

When running a signal.istft with boundary equal to False I get a warning telling me that the NOLA condition failed. However when I use the signal.check_NOLA function it tells me that the condition is satisfied, this is counterintuitive. 

When I check the NOLA condition myself it is indeed satisfied. However the inverse short time fourier transformation is not able to convert back to the original signal because it cannot calculate the values at the boundaries.

### Describe the solution you'd like.

My suggestion would be to change the warning message as the current message is misleading. 

### Describe alternatives you've considered.

Explain in de documentation.

### Additional context (e.g. screenshots, GIFs)

minimal example:

```python
import numpy as np
from scipy import signal

data = np.sin(np.arange(0,100))
f, t, Zxx = signal.stft(data, 10, nperseg=20, noverlap=18, padded=False, boundary=None)
t, data = signal.istft(Zxx, fs=10, nperseg=20, noverlap=18, boundary=False) #Gives "NOLA condition failed, STFT may not be invertible" warning

signal.check_NOLA(signal.get_window("hann", 20), nperseg=20, noverlap=18) # Gives True

```

Hints from issue discussion:

Commit message: ENH: Warn about missing boundary when NOLA condition failed in ISTFT #17885

Patch to review:
diff --git a/scipy/signal/_spectral_py.py b/scipy/signal/_spectral_py.py
index 29a14da5f5a3..f70b9ab55130 100644
--- a/scipy/signal/_spectral_py.py
+++ b/scipy/signal/_spectral_py.py
@@ -1489,7 +1489,7 @@ def istft(Zxx, fs=1.0, window='hann', nperseg=None, noverlap=None, nfft=None,
 
     # Divide out normalization where non-tiny
     if np.sum(norm > 1e-10) != len(norm):
-        warnings.warn("NOLA condition failed, STFT may not be invertible")
+        warnings.warn("NOLA condition failed, STFT may not be invertible. " + ("Possibly due to missing boundary" if boundary else ""))
     x /= np.where(norm > 1e-10, norm, 1.0)
 
     if input_onesided:


Code review comments:
diff_hunk: @@ -1489,7 +1489,7 @@ def istft(Zxx, fs=1.0, window='hann', nperseg=None, noverlap=None, nfft=None,
 
     # Divide out normalization where non-tiny
     if np.sum(norm > 1e-10) != len(norm):
-        warnings.warn("NOLA condition failed, STFT may not be invertible")
+        warnings.warn("NOLA condition failed, STFT may not be invertible. " + ("Possibly due to missing boundary" if boundary else ""))
path: scipy/signal/_spectral_py.py
text: @user1:
This line is too long.
```suggestion
        warnings.warn(
            "NOLA condition failed, STFT may not be invertible."
            + (" Possibly due to missing boundary" if boundary else "")
        )
```