diff --git a/statsmodels/stats/tests/test_weightstats.py b/statsmodels/stats/tests/test_weightstats.py index 093205005f3..40c54ffc156 100644 --- a/statsmodels/stats/tests/test_weightstats.py +++ b/statsmodels/stats/tests/test_weightstats.py @@ -760,3 +760,10 @@ def test(self): ci = d1.zconfint_mean(alternative=alternatives[tc.alternative]) assert_allclose(ci, tc_conf_int, rtol=1e-10) + + +def test_weightstats_len_1(): + x1 = [1] + w1 = [1] + d1 = DescrStatsW(x1, w1) + assert (d1.quantile([0.0, 0.5, 1.0]) == 1).all() diff --git a/statsmodels/stats/weightstats.py b/statsmodels/stats/weightstats.py index 56a271a16d5..52d0395764a 100644 --- a/statsmodels/stats/weightstats.py +++ b/statsmodels/stats/weightstats.py @@ -109,7 +109,7 @@ def __init__(self, data, weights=None, ddof=0): else: self.weights = np.asarray(weights).astype(float) # TODO: why squeeze? - if len(weights.shape) > 1: + if len(self.weights.shape) > 1: self.weights = self.weights.squeeze() self.ddof = ddof