Skip to content

Commit

Permalink
Compat with older statsmodels
Browse files Browse the repository at this point in the history
  • Loading branch information
mwaskom committed May 8, 2020
1 parent 36ad4fa commit 31dd186
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions seaborn/distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,9 @@ def _statsmodels_univariate_kde(data, kernel, bw, gridsize, cut, clip,
fft = kernel == "gau"
kde = smnp.KDEUnivariate(data)

# statsmodels 0.8 fails on int type data
data = data.astype(np.float64)

try:
kde.fit(kernel, bw, fft, gridsize=gridsize, cut=cut, clip=clip)
except RuntimeError as err: # GH#1990
Expand Down Expand Up @@ -471,6 +474,10 @@ def _bivariate_kdeplot(x, y, filled, fill_lowest,

def _statsmodels_bivariate_kde(x, y, bw, gridsize, cut, clip):
"""Compute a bivariate kde using statsmodels."""
# statsmodels 0.8 fails on int type data
x = x.astype(np.float64)
y = y.astype(np.float64)

if isinstance(bw, str):
bw_func = getattr(smnp.bandwidths, "bw_" + bw)
x_bw = bw_func(x)
Expand Down

0 comments on commit 31dd186

Please sign in to comment.