Skip to content

Commit 993af1f

Browse files
authored
Merge pull request statsmodels#8826 from bashtage/pre-deprecations
MAINT/DOC: Fix more deprecations and restore doc build
2 parents f745e5b + a653598 commit 993af1f

File tree

11 files changed

+30
-12
lines changed

11 files changed

+30
-12
lines changed

docs/source/contingency_tables.rst

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ contingency table cell counts:
5050
import statsmodels.api as sm
5151
5252
df = sm.datasets.get_rdataset("Arthritis", "vcd").data
53+
df.fillna({"Improved":"None"}, inplace=True)
5354
5455
tab = pd.crosstab(df['Treatment'], df['Improved'])
5556
tab = tab.loc[:, ["None", "Some", "Marked"]]

docs/source/plots/stl_plot.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import numpy as np
12
import matplotlib.pyplot as plt
23
from pandas.plotting import register_matplotlib_converters
34

@@ -8,6 +9,6 @@
89
data = co2.load().data
910
data = data.resample('M').mean().ffill()
1011

11-
res = STL(data).fit()
12+
res = STL(np.squeeze(data)).fit()
1213
res.plot()
1314
plt.show()

docs/source/treatment.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11

22
.. module:: statsmodels.treatment
3-
.. currentmodule:: statsmodels.treatment
43
:synopsis: Treatment Effect
54

5+
.. currentmodule:: statsmodels.treatment
6+
7+
68

79
.. _othermod:
810

requirements-doc.txt

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Requirements for doc build, in addition to requirements.txt
22
sphinx>=5,<6
3+
# Avoid warnings which break Sphinx by pinning pandas
4+
pandas>=2.0,<2.1
35
sphinx-material
46
jupyter
57
notebook
@@ -14,3 +16,4 @@ theano-pymc; os_name != "nt"
1416
pymc3; os_name != "nt"
1517
arviz; os_name != "nt"
1618
jinja2==3.0.3
19+

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ filterwarnings =
7777
error:The probit link alias is deprecated:FutureWarning:
7878
error:Parsing dates in:UserWarning
7979
error:A value is trying to be set on a copy::
80-
error:Conversion of an array with ndim:DeprecationWarning:statsmodels
80+
error:Conversion of an array with ndim:DeprecationWarning:
8181
markers =
8282
example: mark a test that runs example code
8383
matplotlib: mark a test that requires matplotlib

statsmodels/datasets/danish_data/data.py

+5
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ def load():
6060

6161
def _get_data():
6262
data = du.load_csv(__file__, "data.csv")
63+
for i, val in enumerate(data.period):
64+
parts = val.split("Q")
65+
month = (int(parts[1]) - 1) * 3 + 1
66+
67+
data.loc[data.index[i], "period"] = f"{parts[0]}-{month:02d}-01"
6368
data["period"] = pd.to_datetime(data.period)
6469
return data.set_index("period").astype(float)
6570

statsmodels/distributions/copula/archimedean.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ def _debye(alpha):
2121
EPSILON = np.finfo(np.float64).eps * 100
2222

2323
def integrand(t):
24-
return t / (np.exp(t) - 1)
25-
26-
debye_value = integrate.quad(integrand, EPSILON, alpha)[0] / alpha
24+
return np.squeeze(t / (np.exp(t) - 1))
25+
_alpha = np.squeeze(alpha)
26+
debye_value = integrate.quad(integrand, EPSILON, _alpha)[0] / _alpha
2727
return debye_value
2828

2929

statsmodels/emplike/originregress.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ def conf_int_el(self, param_num, upper_bound=None,
250250
f = lambda b0: self.el_test(np.array([b0]), param_num,
251251
method=method,
252252
stochastic_exog=stochastic_exog)[0] - r0
253-
lowerl = optimize.brentq(f, lower_bound, self.params[param_num])
254-
upperl = optimize.brentq(f, self.params[param_num], upper_bound)
253+
_param = np.squeeze(self.params[param_num])
254+
lowerl = optimize.brentq(f, np.squeeze(lower_bound), _param)
255+
upperl = optimize.brentq(f, _param, np.squeeze(upper_bound))
255256
return (lowerl, upperl)

statsmodels/genmod/families/tests/test_family.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,10 @@ def test_tweedie_loglike_obs(power):
100100
scale = 2.9
101101

102102
def pdf(y):
103-
return np.exp(tweedie.loglike_obs(
104-
endog=y, mu=mu, scale=scale
105-
))
103+
return np.squeeze(
104+
np.exp(
105+
tweedie.loglike_obs(endog=y, mu=mu, scale=scale)
106+
)
107+
)
106108

107109
assert_allclose(pdf(0) + integrate.quad(pdf, 0, 1e2)[0], 1, atol=1e-4)

statsmodels/sandbox/distributions/extras.py

+1
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,7 @@ def _sf(self, x, *args, **kwargs):
817817
return 1.0 - self._cdf(x, *args, **kwargs)
818818

819819
def _munp(self, n, *args, **kwargs):
820+
args = [np.squeeze(arg) for arg in args]
820821
out = np.squeeze(self._mom0_sc(n, *args))
821822
if np.isscalar(out):
822823
return float(out)

statsmodels/sandbox/distributions/tests/test_transf.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def setup_class(cls):
101101

102102
def test_equivalent(self):
103103
xx, ppfq = self.xx, self.ppfq
104-
for d1,d2 in self.dist_equivalents:
104+
for j,(d1,d2) in enumerate(self.dist_equivalents):
105105
## print d1.name
106106
assert_almost_equal(d1.cdf(xx), d2.cdf(xx), err_msg='cdf'+d1.name)
107107
assert_almost_equal(d1.pdf(xx), d2.pdf(xx),
@@ -122,6 +122,8 @@ def test_equivalent(self):
122122
d2mom = d2.dist.moment(3, *d2.args)
123123
else:
124124
d2mom = d2.moment(3)
125+
if j==3:
126+
print("now")
125127
assert_almost_equal(d1.moment(3), d2mom,
126128
DECIMAL,
127129
err_msg='moment '+d1.name+d2.name)

0 commit comments

Comments
 (0)