Skip to content

Commit 7610de9

Browse files
authored
Merge pull request statsmodels#6126 from bashtage/more-docs
DOC: Update templates and add missing API functions
2 parents 5d1cb37 + cc92ab5 commit 7610de9

File tree

9 files changed

+82
-50
lines changed

9 files changed

+82
-50
lines changed

docs/source/_templates/autosummary/attribute.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,5 @@
44

55
.. currentmodule:: {{ module }}
66

7-
attribute
8-
97
.. auto{{ objtype }}:: {{ objname }}
108

docs/source/_templates/autosummary/member.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
.. currentmodule:: {{ module }}
66

7-
member
8-
97
.. auto{{ objtype }}:: {{ objname }}
108
119

docs/source/_templates/autosummary/method.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,5 @@
44

55
.. currentmodule:: {{ module }}
66

7-
method
8-
97
.. auto{{ objtype }}:: {{ objname }}
108

docs/source/gee.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ Model Class
6969
:toctree: generated/
7070

7171
GEE
72+
NominalGEE
73+
OrdinalGEE
7274

7375
.. module:: statsmodels.genmod.qif
7476
:synopsis: Quadratic inference functions

docs/source/gettingstarted.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,17 @@ plot of partial regression for a set of regressors by:
175175
sm.graphics.plot_partregress('Lottery', 'Wealth', ['Region', 'Literacy'],
176176
data=df, obs_labels=False)
177177
178+
Documentation
179+
-------------
180+
Documentation can be accessed from an IPython session
181+
using :func:`~statsmodels.tools.web.webdoc`.
182+
183+
.. autosummary::
184+
:nosignatures:
185+
:toctree: generated/
186+
187+
~statsmodels.tools.web.webdoc
188+
178189
More
179190
----
180191

statsmodels/genmod/generalized_estimating_equations.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,8 @@ def _check_args(endog, exog, groups, time, offset, exposure):
472472
class GEE(base.Model):
473473

474474
__doc__ = (
475-
" Estimation of marginal regression models using Generalized\n"
476-
" Estimating Equations (GEE).\n" + _gee_init_doc %
475+
" Marginal Regression Model using Generalized Estimating "
476+
"Equations.\n" + _gee_init_doc %
477477
{'extra_params': base._missing_param_doc,
478478
'family_doc': _gee_family_doc,
479479
'example': _gee_example})
@@ -2346,8 +2346,7 @@ class GEEResultsWrapper(lm.RegressionResultsWrapper):
23462346
class OrdinalGEE(GEE):
23472347

23482348
__doc__ = (
2349-
" Estimation of ordinal response marginal regression models\n"
2350-
" using Generalized Estimating Equations (GEE).\n" +
2349+
" Ordinal Response Marginal Regression Model using GEE\n" +
23512350
_gee_init_doc % {'extra_params': base._missing_param_doc,
23522351
'family_doc': _gee_ordinal_family_doc,
23532352
'example': _gee_ordinal_example})
@@ -2628,8 +2627,7 @@ class OrdinalGEEResultsWrapper(GEEResultsWrapper):
26282627
class NominalGEE(GEE):
26292628

26302629
__doc__ = (
2631-
" Estimation of nominal response marginal regression models\n"
2632-
" using Generalized Estimating Equations (GEE).\n" +
2630+
" Nominal Response Marginal Regression Model using GEE.\n" +
26332631
_gee_init_doc % {'extra_params': base._missing_param_doc,
26342632
'family_doc': _gee_nominal_family_doc,
26352633
'example': _gee_nominal_example})

statsmodels/tools/tests/test_web.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,35 @@
1-
from statsmodels.tools.web import _generate_url, webdoc
2-
from statsmodels.regression.linear_model import OLS
3-
from numpy import array
41
import pytest
2+
from numpy import array
3+
4+
from statsmodels.regression.linear_model import OLS
5+
from statsmodels.tools.web import _generate_url, webdoc
6+
57

68
class TestWeb(object):
9+
stable = 'https://www.statsmodels.org/stable/'
10+
devel = 'https://www.statsmodels.org/devel/'
11+
712
def test_string(self):
8-
url = _generate_url('arch',True)
9-
assert url == 'https://www.statsmodels.org/stable/search.html?q=arch&check_keywords=yes&area=default'
10-
url = _generate_url('arch',False)
11-
assert url == 'https://www.statsmodels.org/devel/search.html?q=arch&check_keywords=yes&area=default'
12-
url = _generate_url('dickey fuller',False)
13-
assert url == 'https://www.statsmodels.org/devel/search.html?q=dickey+fuller&check_keywords=yes&area=default'
13+
url = _generate_url('arch', True)
14+
assert url == self.stable + 'search.html?q=' \
15+
'arch&check_keywords=yes&area=default'
16+
url = _generate_url('arch', False)
17+
assert url == self.devel + 'search.html?q=' \
18+
'arch&check_keywords=yes&area=default'
19+
url = _generate_url('dickey fuller', False)
20+
assert url == (self.devel +
21+
'search.html?q='
22+
'dickey+fuller&check_keywords=yes&area=default')
1423

1524
def test_function(self):
1625
url = _generate_url(OLS, True)
17-
assert url == 'https://www.statsmodels.org/stable/generated/statsmodels.regression.linear_model.OLS.html'
26+
assert url == (self.stable
27+
+ 'generated/'
28+
'statsmodels.regression.linear_model.OLS.html')
1829
url = _generate_url(OLS, False)
19-
assert url == 'https://www.statsmodels.org/devel/generated/statsmodels.regression.linear_model.OLS.html'
30+
assert url == (self.devel
31+
+ 'generated/'
32+
'statsmodels.regression.linear_model.OLS.html')
2033

2134
def test_nothing(self):
2235
url = _generate_url(None, True)

statsmodels/tools/tools.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ def drop_missing(Y, X=None, axis=1):
7474
# TODO: add name validator (ie., bad names for datasets.grunfeld)
7575
def categorical(data, col=None, dictnames=False, drop=False):
7676
"""
77-
Construct a dummy matrix given an array of categorical variables.
77+
Construct a dummy matrix from categorical variables
7878
7979
Parameters
8080
----------
81-
data : array
81+
data : array_like
8282
A structured array, recarray, array, Series or DataFrame. This can be
8383
either a 1d vector of the categorical variable or a 2d array with
8484
the column specifying the categorical variable specified by the col
@@ -98,14 +98,15 @@ def categorical(data, col=None, dictnames=False, drop=False):
9898
9999
Returns
100100
-------
101-
dummy_matrix, [dictnames, optional]
101+
dummy_matrix : array_like
102102
A matrix of dummy (indicator/binary) float variables for the
103-
categorical data. If dictnames is True, then the dictionary
104-
is returned as well.
103+
categorical data.
104+
dictnames : dict[int, str], optional
105+
Mapping between column numbers and categorical names.
105106
106107
Notes
107108
-----
108-
This returns a dummy variable for EVERY distinct variable. If a
109+
This returns a dummy variable for *each* distinct variable. If a
109110
a structured or recarray is provided, the names for the new variable is the
110111
old variable name - underscore - category name. So if the a variable
111112
'vote' had answers as 'yes' or 'no' then the returned array would have to
@@ -120,11 +121,11 @@ def categorical(data, col=None, dictnames=False, drop=False):
120121
Univariate examples
121122
122123
>>> import string
123-
>>> string_var = [string.ascii_lowercase[0:5], \
124-
string.ascii_lowercase[5:10], \
125-
string.ascii_lowercase[10:15], \
126-
string.ascii_lowercase[15:20], \
127-
string.ascii_lowercase[20:25]]
124+
>>> string_var = [string.ascii_lowercase[0:5],
125+
... string.ascii_lowercase[5:10],
126+
... string.ascii_lowercase[10:15],
127+
... string.ascii_lowercase[15:20],
128+
... string.ascii_lowercase[20:25]]
128129
>>> string_var *= 5
129130
>>> string_var = np.asarray(sorted(string_var))
130131
>>> design = sm.tools.categorical(string_var, drop=True)
@@ -137,8 +138,9 @@ def categorical(data, col=None, dictnames=False, drop=False):
137138
With a structured array
138139
139140
>>> num = np.random.randn(25,2)
140-
>>> struct_ar = np.zeros((25,1), dtype=[('var1', 'f4'),('var2', 'f4'), \
141-
('instrument','f4'),('str_instr','a5')])
141+
>>> struct_ar = np.zeros((25,1),
142+
... dtype=[('var1', 'f4'),('var2', 'f4'),
143+
... ('instrument','f4'),('str_instr','a5')])
142144
>>> struct_ar['var1'] = num[:,0][:,None]
143145
>>> struct_ar['var2'] = num[:,1][:,None]
144146
>>> struct_ar['instrument'] = instr[:,None]

statsmodels/tools/web.py

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Provides a function to open the system browser to either search or go directly
33
to a function's reference
44
"""
5+
from statsmodels.compat.pandas import deprecate_kwarg
6+
57
import webbrowser
68
from urllib.parse import urlencode
79

@@ -10,7 +12,7 @@
1012
BASE_URL = 'https://www.statsmodels.org/'
1113

1214

13-
def _generate_url(arg, stable):
15+
def _generate_url(func, stable):
1416
"""
1517
Parse inputs and return a correctly formatted URL or raises ValueError
1618
if the input is not understandable
@@ -21,15 +23,15 @@ def _generate_url(arg, stable):
2123
else:
2224
url += 'devel/'
2325

24-
if arg is None:
26+
if func is None:
2527
return url
26-
elif isinstance(arg, str):
28+
elif isinstance(func, str):
2729
url += 'search.html?'
28-
url += urlencode({'q': arg})
30+
url += urlencode({'q': func})
2931
url += '&check_keywords=yes&area=default'
3032
else:
3133
try:
32-
func = arg
34+
func = func
3335
func_name = func.__name__
3436
func_module = func.__module__
3537
if not func_module.startswith('statsmodels.'):
@@ -41,15 +43,16 @@ def _generate_url(arg, stable):
4143
return url
4244

4345

44-
def webdoc(arg=None, stable=None):
46+
@deprecate_kwarg('arg', 'func')
47+
def webdoc(func=None, stable=None):
4548
"""
4649
Opens a browser and displays online documentation
4750
4851
Parameters
4952
----------
50-
arg, optional : str or statsmodels function
53+
func : {str, callable}
5154
Either a string to search the documentation or a function
52-
stable, optional : bool
55+
stable : bool
5356
Flag indicating whether to use the stable documentation (True) or
5457
the development documentation (False). If not provided, opens
5558
the stable documentation if the current version of statsmodels is a
@@ -58,18 +61,27 @@ def webdoc(arg=None, stable=None):
5861
Examples
5962
--------
6063
>>> import statsmodels.api as sm
61-
>>> sm.webdoc() # Documention site
62-
>>> sm.webdoc('glm') # Search for glm in docs
63-
>>> sm.webdoc(sm.OLS, stable=False) # Go to generated help for OLS, devel
64+
65+
Documentation site
66+
67+
>>> sm.webdoc()
68+
69+
Search for glm in docs
70+
71+
>>> sm.webdoc('glm')
72+
73+
Go to current generated help for OLS
74+
75+
>>> sm.webdoc(sm.OLS, stable=False)
6476
6577
Notes
6678
-----
67-
By default, open stable documentation if the current version of statsmodels
68-
is a release. Otherwise opens the development documentation.
79+
By default, open stable documentation if the current version of
80+
statsmodels is a release. Otherwise opens the development documentation.
6981
7082
Uses the default system browser.
7183
"""
7284
stable = __version__ if 'dev' not in __version__ else stable
73-
url_or_error = _generate_url(arg, stable)
85+
url_or_error = _generate_url(func, stable)
7486
webbrowser.open(url_or_error)
7587
return None

0 commit comments

Comments
 (0)