def test_warning_smaller_n_bins():
    """Test that a warning is raised when n_bins will be smaller."""
    X_new = np.r_[np.zeros((1, n_timestamps)), X]
    discretizer = KBinsDiscretizer()
    warning_msg = (
        "Some quantiles are equal. The number of bins will be "
        "smaller for sample {0}. Consider decreasing the number "
        "of bins or removing these samples.".format([0])
    )
    with pytest.warns(UserWarning, match=re.escape(warning_msg)):
        discretizer._compute_bins(
            X_new, n_samples + 1, n_bins=5, strategy='quantile'
        )
Test that a warning is raised when n_bins will be smaller.
pyts/preprocessing/tests/test_discretizer.py