Skip to content

Commit

Permalink
Test weightstats with len 1 array
Browse files Browse the repository at this point in the history
  • Loading branch information
brl0 committed Sep 19, 2020
1 parent 2fcbc3c commit adfa4e7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions statsmodels/stats/tests/test_weightstats.py
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion statsmodels/stats/weightstats.py
Expand Up @@ -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

Expand Down

0 comments on commit adfa4e7

Please sign in to comment.