Skip to content

Commit 7d9a7ab

Browse files
rpgoldmantwiecki
authored andcommitted
Fix docstrings.
Added raw string qualifiers for docstrings that were causing the deprecation warnings in issue #3878. In passing, fixed some other minor docstring formatting issues.
1 parent 683faaa commit 7d9a7ab

File tree

11 files changed

+102
-86
lines changed

11 files changed

+102
-86
lines changed

pymc3/distributions/continuous.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def assert_negative_support(var, label, distname, value=-1e-6):
103103

104104

105105
def get_tau_sigma(tau=None, sigma=None):
106-
"""
106+
r"""
107107
Find precision and standard deviation. The link between the two
108108
parameterizations is given by the inverse relationship:
109109
@@ -770,7 +770,7 @@ def _repr_latex_(self, name=None, dist=None):
770770
name = r'\text{%s}' % name
771771
return (
772772
r'${} \sim \text{{TruncatedNormal}}('
773-
'\mathit{{mu}}={},~\mathit{{sigma}}={},a={},b={})$'
773+
r'\mathit{{mu}}={},~\mathit{{sigma}}={},a={},b={})$'
774774
.format(
775775
name,
776776
get_variable_name(self.mu),
@@ -2968,7 +2968,7 @@ def _repr_latex_(self, name=None, dist=None):
29682968
get_variable_name(beta))
29692969

29702970
def logcdf(self, value):
2971-
"""
2971+
r"""
29722972
Compute the log of the cumulative distribution function for Weibull distribution
29732973
at the specified value.
29742974
@@ -4130,7 +4130,7 @@ def _repr_latex_(self, name=None, dist=None):
41304130
get_variable_name(s))
41314131

41324132
def logcdf(self, value):
4133-
"""
4133+
r"""
41344134
Compute the log of the cumulative distribution function for Logistic distribution
41354135
at the specified value.
41364136

pymc3/distributions/discrete.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def __init__(self, n, p, *args, **kwargs):
8080
self.mode = tt.cast(tround(n * p), self.dtype)
8181

8282
def random(self, point=None, size=None):
83-
"""
83+
r"""
8484
Draw random values from Binomial distribution.
8585
8686
Parameters
@@ -102,7 +102,7 @@ def random(self, point=None, size=None):
102102
size=size)
103103

104104
def logp(self, value):
105-
"""
105+
r"""
106106
Calculate log-probability of Binomial distribution at specified value.
107107
108108
Parameters
@@ -215,7 +215,7 @@ def _random(self, alpha, beta, n, size=None):
215215
return samples
216216

217217
def random(self, point=None, size=None):
218-
"""
218+
r"""
219219
Draw random values from BetaBinomial distribution.
220220
221221
Parameters
@@ -238,7 +238,7 @@ def random(self, point=None, size=None):
238238
size=size)
239239

240240
def logp(self, value):
241-
"""
241+
r"""
242242
Calculate log-probability of BetaBinomial distribution at specified value.
243243
244244
Parameters
@@ -326,7 +326,7 @@ def __init__(self, p=None, logit_p=None, *args, **kwargs):
326326
self.mode = tt.cast(tround(self.p), 'int8')
327327

328328
def random(self, point=None, size=None):
329-
"""
329+
r"""
330330
Draw random values from Bernoulli distribution.
331331
332332
Parameters
@@ -348,7 +348,7 @@ def random(self, point=None, size=None):
348348
size=size)
349349

350350
def logp(self, value):
351-
"""
351+
r"""
352352
Calculate log-probability of Bernoulli distribution at specified value.
353353
354354
Parameters
@@ -427,7 +427,7 @@ def __init__(self, q, beta, *args, **kwargs):
427427
self.median = self._ppf(0.5)
428428

429429
def logp(self, value):
430-
"""
430+
r"""
431431
Calculate log-probability of DiscreteWeibull distribution at specified value.
432432
433433
Parameters
@@ -449,7 +449,7 @@ def logp(self, value):
449449
0 < beta)
450450

451451
def _ppf(self, p):
452-
"""
452+
r"""
453453
The percentile point function (the inverse of the cumulative
454454
distribution function) of the discrete Weibull distribution.
455455
"""
@@ -464,7 +464,7 @@ def _random(self, q, beta, size=None):
464464
return np.ceil(np.power(np.log(1 - p) / np.log(q), 1. / beta)) - 1
465465

466466
def random(self, point=None, size=None):
467-
"""
467+
r"""
468468
Draw random values from DiscreteWeibull distribution.
469469
470470
Parameters
@@ -547,7 +547,7 @@ def __init__(self, mu, *args, **kwargs):
547547
self.mode = intX(tt.floor(mu))
548548

549549
def random(self, point=None, size=None):
550-
"""
550+
r"""
551551
Draw random values from Poisson distribution.
552552
553553
Parameters
@@ -569,7 +569,7 @@ def random(self, point=None, size=None):
569569
size=size)
570570

571571
def logp(self, value):
572-
"""
572+
r"""
573573
Calculate log-probability of Poisson distribution at specified value.
574574
575575
Parameters
@@ -656,7 +656,7 @@ def __init__(self, mu, alpha, *args, **kwargs):
656656
self.mode = intX(tt.floor(mu))
657657

658658
def random(self, point=None, size=None):
659-
"""
659+
r"""
660660
Draw random values from NegativeBinomial distribution.
661661
662662
Parameters
@@ -680,7 +680,7 @@ def random(self, point=None, size=None):
680680
return np.asarray(stats.poisson.rvs(g)).reshape(g.shape)
681681

682682
def _random(self, mu, alpha, size):
683-
""" Wrapper around stats.gamma.rvs that converts NegativeBinomial's
683+
r""" Wrapper around stats.gamma.rvs that converts NegativeBinomial's
684684
parametrization to scipy.gamma. All parameter arrays should have
685685
been broadcasted properly by generate_samples at this point and size is
686686
the scipy.rvs representation.
@@ -692,7 +692,7 @@ def _random(self, mu, alpha, size):
692692
)
693693

694694
def logp(self, value):
695-
"""
695+
r"""
696696
Calculate log-probability of NegativeBinomial distribution at specified value.
697697
698698
Parameters
@@ -771,7 +771,7 @@ def __init__(self, p, *args, **kwargs):
771771
self.mode = 1
772772

773773
def random(self, point=None, size=None):
774-
"""
774+
r"""
775775
Draw random values from Geometric distribution.
776776
777777
Parameters
@@ -793,7 +793,7 @@ def random(self, point=None, size=None):
793793
size=size)
794794

795795
def logp(self, value):
796-
"""
796+
r"""
797797
Calculate log-probability of Geometric distribution at specified value.
798798
799799
Parameters
@@ -872,7 +872,7 @@ def _random(self, lower, upper, size=None):
872872
return samples
873873

874874
def random(self, point=None, size=None):
875-
"""
875+
r"""
876876
Draw random values from DiscreteUniform distribution.
877877
878878
Parameters
@@ -895,7 +895,7 @@ def random(self, point=None, size=None):
895895
size=size)
896896

897897
def logp(self, value):
898-
"""
898+
r"""
899899
Calculate log-probability of DiscreteUniform distribution at specified value.
900900
901901
Parameters
@@ -975,7 +975,7 @@ def __init__(self, p, *args, **kwargs):
975975
self.mode = tt.squeeze(self.mode)
976976

977977
def random(self, point=None, size=None):
978-
"""
978+
r"""
979979
Draw random values from Categorical distribution.
980980
981981
Parameters
@@ -1001,7 +1001,7 @@ def random(self, point=None, size=None):
10011001
size=size)
10021002

10031003
def logp(self, value):
1004-
"""
1004+
r"""
10051005
Calculate log-probability of Categorical distribution at specified value.
10061006
10071007
Parameters
@@ -1054,7 +1054,7 @@ def _repr_latex_(self, name=None, dist=None):
10541054

10551055

10561056
class Constant(Discrete):
1057-
"""
1057+
r"""
10581058
Constant log-likelihood.
10591059
10601060
Parameters
@@ -1070,7 +1070,7 @@ def __init__(self, c, *args, **kwargs):
10701070
self.mean = self.median = self.mode = self.c = c = tt.as_tensor_variable(c)
10711071

10721072
def random(self, point=None, size=None):
1073-
"""
1073+
r"""
10741074
Draw random values from Constant distribution.
10751075
10761076
Parameters
@@ -1096,7 +1096,7 @@ def _random(c, dtype=dtype, size=None):
10961096
size=size).astype(dtype)
10971097

10981098
def logp(self, value):
1099-
"""
1099+
r"""
11001100
Calculate log-probability of Constant distribution at specified value.
11011101
11021102
Parameters
@@ -1180,7 +1180,7 @@ def __init__(self, psi, theta, *args, **kwargs):
11801180
self.mode = self.pois.mode
11811181

11821182
def random(self, point=None, size=None):
1183-
"""
1183+
r"""
11841184
Draw random values from ZeroInflatedPoisson distribution.
11851185
11861186
Parameters
@@ -1204,7 +1204,7 @@ def random(self, point=None, size=None):
12041204
return g * (np.random.random(g.shape) < psi)
12051205

12061206
def logp(self, value):
1207-
"""
1207+
r"""
12081208
Calculate log-probability of ZeroInflatedPoisson distribution at specified value.
12091209
12101210
Parameters
@@ -1302,7 +1302,7 @@ def __init__(self, psi, n, p, *args, **kwargs):
13021302
self.mode = self.bin.mode
13031303

13041304
def random(self, point=None, size=None):
1305-
"""
1305+
r"""
13061306
Draw random values from ZeroInflatedBinomial distribution.
13071307
13081308
Parameters
@@ -1326,7 +1326,7 @@ def random(self, point=None, size=None):
13261326
return g * (np.random.random(g.shape) < psi)
13271327

13281328
def logp(self, value):
1329-
"""
1329+
r"""
13301330
Calculate log-probability of ZeroInflatedBinomial distribution at specified value.
13311331
13321332
Parameters
@@ -1448,7 +1448,7 @@ def __init__(self, psi, mu, alpha, *args, **kwargs):
14481448
self.mode = self.nb.mode
14491449

14501450
def random(self, point=None, size=None):
1451-
"""
1451+
r"""
14521452
Draw random values from ZeroInflatedNegativeBinomial distribution.
14531453
14541454
Parameters
@@ -1478,7 +1478,7 @@ def random(self, point=None, size=None):
14781478
return stats.poisson.rvs(g) * (np.random.random(g.shape) < psi)
14791479

14801480
def _random(self, mu, alpha, size):
1481-
""" Wrapper around stats.gamma.rvs that converts NegativeBinomial's
1481+
r""" Wrapper around stats.gamma.rvs that converts NegativeBinomial's
14821482
parametrization to scipy.gamma. All parameter arrays should have
14831483
been broadcasted properly by generate_samples at this point and size is
14841484
the scipy.rvs representation.
@@ -1490,7 +1490,7 @@ def _random(self, mu, alpha, size):
14901490
)
14911491

14921492
def logp(self, value):
1493-
"""
1493+
r"""
14941494
Calculate log-probability of ZeroInflatedNegativeBinomial distribution at specified value.
14951495
14961496
Parameters

pymc3/gp/gp.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def conditional(self, name, Xnew, given=None, **kwargs):
224224

225225
@conditioned_vars(["X", "f", "nu"])
226226
class TP(Latent):
227-
"""
227+
r"""
228228
Student's T process prior.
229229
230230
The usage is nearly identical to that of `gp.Latent`. The differences
@@ -239,11 +239,11 @@ class TP(Latent):
239239
240240
Parameters
241241
----------
242-
cov_func: None, 2D array, or instance of Covariance
242+
cov_func : None, 2D array, or instance of Covariance
243243
The covariance function. Defaults to zero.
244-
mean_func: None, instance of Mean
244+
mean_func : None, instance of Mean
245245
The mean function. Defaults to zero.
246-
nu: float
246+
nu : float
247247
The degrees of freedom
248248
249249
References

pymc3/math.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,18 @@
3737

3838

3939
def kronecker(*Ks):
40-
"""Return the Kronecker product of arguments:
40+
r"""Return the Kronecker product of arguments:
4141
:math:`K_1 \otimes K_2 \otimes ... \otimes K_D`
4242
4343
Parameters
4444
----------
45-
Ks: 2D array-like
45+
Ks : Iterable of 2D array-like
46+
Arrays of which to take the product.
47+
48+
Returns
49+
-------
50+
np.ndarray :
51+
Block matrix Kroncker product of the argument matrices.
4652
"""
4753
return reduce(tt.slinalg.kron, Ks)
4854

@@ -60,16 +66,20 @@ def cartesian(*arrays):
6066

6167

6268
def kron_matrix_op(krons, m, op):
63-
"""Apply op to krons and m in a way that reproduces ``op(kronecker(*krons), m)``
69+
r"""Apply op to krons and m in a way that reproduces ``op(kronecker(*krons), m)``
6470
6571
Parameters
6672
-----------
67-
krons: list of square 2D array-like objects
68-
D square matrices :math:`[A_1, A_2, ..., A_D]` to be Kronecker'ed
69-
:math:`A = A_1 \otimes A_2 \otimes ... \otimes A_D`
70-
Product of column dimensions must be :math:`N`
71-
m : NxM array or 1D array (treated as Nx1)
72-
Object that krons act upon
73+
krons : list of square 2D array-like objects
74+
D square matrices :math:`[A_1, A_2, ..., A_D]` to be Kronecker'ed
75+
:math:`A = A_1 \otimes A_2 \otimes ... \otimes A_D`
76+
Product of column dimensions must be :math:`N`
77+
m : NxM array or 1D array (treated as Nx1)
78+
Object that krons act upon
79+
80+
Returns
81+
-------
82+
numpy array
7383
"""
7484
def flat_matrix_op(flat_mat, mat):
7585
Nmat = mat.shape[1]

0 commit comments

Comments
 (0)