Skip to content

Commit c3b03c6

Browse files
committed
Put summary line on only one line (D205)
1 parent 0152862 commit c3b03c6

39 files changed

+301
-333
lines changed

benchmarks/benchmarks/benchmarks.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,7 @@ def mixture_model(random_seed=1234):
7777

7878

7979
class OverheadSuite:
80-
"""
81-
Just tests how long sampling from a normal distribution takes for various
82-
samplers.
83-
"""
80+
"""Test how long sampling from a normal distribution takes for various samplers."""
8481

8582
params = [pm.NUTS, pm.HamiltonianMC, pm.Metropolis, pm.Slice]
8683
timer = timeit.default_timer

pymc/backends/base.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,12 @@ def _slice(self, idx: slice) -> "IBaseTrace":
102102
raise NotImplementedError()
103103

104104
def point(self, idx: int) -> dict[str, np.ndarray]:
105-
"""Return dictionary of point values at `idx` for current chain
106-
with variables names as keys.
105+
"""Return point values at `idx` for current chain.
106+
107+
Returns
108+
-------
109+
values : dict[str, np.ndarray]
110+
Dictionary of values with variable names as keys.
107111
"""
108112
raise NotImplementedError()
109113

@@ -568,9 +572,7 @@ def points(self, chains=None):
568572

569573

570574
def _squeeze_cat(results, combine: bool, squeeze: bool):
571-
"""Squeeze and concatenate the results depending on values of
572-
`combine` and `squeeze`.
573-
"""
575+
"""Squeeze and/or concatenate the results."""
574576
if combine:
575577
results = np.concatenate(results)
576578
if not squeeze:

pymc/backends/ndarray.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,12 @@ def _slice(self, idx: slice):
184184
return sliced
185185

186186
def point(self, idx) -> dict[str, Any]:
187-
"""Return dictionary of point values at `idx` for current chain
188-
with variable names as keys.
187+
"""Return point values at `idx` for current chain.
188+
189+
Returns
190+
-------
191+
values : dict[str, Any]
192+
Dictionary of values with variable names as keys.
189193
"""
190194
idx = int(idx)
191195
return {varname: values[idx] for varname, values in self.samples.items()}

pymc/data.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ def clone(self):
8787

8888

8989
class GeneratorAdapter:
90-
"""
91-
Helper class that helps to infer data type of generator with looking
92-
at the first item, preserving the order of the resulting generator.
90+
"""Class that helps infer data type of generator.
91+
92+
It looks at the first item, preserving the order of the resulting generator.
9393
"""
9494

9595
def make_variable(self, gop, name=None):

pymc/distributions/continuous.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@
1414

1515
# Contains code from AePPL, Copyright (c) 2021-2022, Aesara Developers.
1616

17-
"""
18-
A collection of common probability distributions for stochastic
19-
nodes in PyMC.
20-
"""
17+
"""A collection of common probability distributions for stochastic nodes in PyMC."""
2118

2219
import warnings
2320

@@ -371,10 +368,7 @@ def rng_fn(cls, rng, size):
371368

372369

373370
class Flat(Continuous):
374-
"""
375-
Uninformative log-likelihood that returns 0 regardless of
376-
the passed value.
377-
"""
371+
"""Uninformative log-likelihood that returns 0 regardless of the passed value."""
378372

379373
rv_op = flat
380374

@@ -3767,8 +3761,7 @@ def rng_fn(cls, rng, x, pdf, cdf, size=None) -> np.ndarray:
37673761

37683762
class Interpolated(BoundedContinuous):
37693763
r"""
3770-
Univariate probability distribution defined as a linear interpolation
3771-
of probability density function evaluated on some lattice of points.
3764+
Univariate linear interpolation of pdf evaluated on some lattice of points.
37723765
37733766
The lattice can be uneven, so the steps between different points can have
37743767
different size and it is possible to vary the precision between regions

pymc/distributions/dist_math.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,16 +172,16 @@ def log_diff_normal_cdf(mu, sigma, x, y):
172172

173173

174174
def sigma2rho(sigma):
175-
"""
176-
`sigma -> rho` PyTensor converter
175+
"""Convert `sigma` into `rho` with PyTensor.
176+
177177
:math:`mu + sigma*e = mu + log(1+exp(rho))*e`.
178178
"""
179179
return pt.log(pt.exp(pt.abs(sigma)) - 1.0)
180180

181181

182182
def rho2sigma(rho):
183-
"""
184-
`rho -> sigma` PyTensor converter
183+
"""Convert `rho` to `sigma` with PyTensor.
184+
185185
:math:`mu + sigma*e = mu + log(1+exp(rho))*e`.
186186
"""
187187
return pt.softplus(rho)
@@ -193,8 +193,7 @@ def rho2sigma(rho):
193193

194194
def log_normal(x, mean, **kwargs):
195195
"""
196-
Calculate logarithm of normal distribution at point `x`
197-
with given `mean` and `std`.
196+
Calculate logarithm of normal distribution at point `x` with given `mean` and `std`.
198197
199198
Parameters
200199
----------

pymc/distributions/distribution.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,9 @@ def support_point(op, rv, *dist_params):
193193

194194

195195
class _class_or_instancemethod(classmethod):
196-
"""Allow a method to be called both as a classmethod and an instancemethod,
197-
giving priority to the instancemethod.
196+
"""Allow a method to be called both as a classmethod and an instancemethod.
197+
198+
Priority is given to the instancemethod.
198199
199200
This is used to allow extracting information from the signature of a SymbolicRandomVariable
200201
which may be provided either as a class attribute or as an instance attribute.
@@ -580,10 +581,7 @@ def dist(
580581

581582
@node_rewriter([SymbolicRandomVariable])
582583
def inline_symbolic_random_variable(fgraph, node):
583-
"""
584-
Optimization that expands the internal graph of a SymbolicRV when obtaining the logp
585-
graph, if the flag `inline_logprob` is True.
586-
"""
584+
"""Expand a SymbolicRV when obtaining the logp graph if `inline_logprob` is True."""
587585
op = node.op
588586
if op.inline_logprob:
589587
return clone_replace(op.inner_outputs, dict(zip(op.inner_inputs, node.inputs)))

pymc/distributions/mixture.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,7 @@ def dist(cls, psi, n, p, **kwargs):
702702
class ZeroInflatedNegativeBinomial:
703703
R"""
704704
Zero-Inflated Negative binomial log-likelihood.
705+
705706
The Zero-inflated version of the Negative Binomial (NB).
706707
The NB distribution describes a Poisson random variable
707708
whose rate parameter is gamma distributed.

pymc/distributions/multivariate.py

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,7 @@ def support_point(rv, size, mu, cov):
279279

280280
def logp(value, mu, cov):
281281
"""
282-
Calculate log-probability of Multivariate Normal distribution
283-
at specified value.
282+
Calculate logp of Multivariate Normal distribution at specified value.
284283
285284
Parameters
286285
----------
@@ -469,8 +468,7 @@ def support_point(rv, size, nu, mu, scale):
469468

470469
def logp(value, nu, mu, scale):
471470
"""
472-
Calculate log-probability of Multivariate Student's T distribution
473-
at specified value.
471+
Calculate logp of Multivariate Student's T distribution at specified value.
474472
475473
Parameters
476474
----------
@@ -535,8 +533,7 @@ def support_point(rv, size, a):
535533

536534
def logp(value, a):
537535
"""
538-
Calculate log-probability of Dirichlet distribution
539-
at specified value.
536+
Calculate logp of Dirichlet distribution at specified value.
540537
541538
Parameters
542539
----------
@@ -642,8 +639,7 @@ def support_point(rv, size, n, p):
642639

643640
def logp(value, n, p):
644641
"""
645-
Calculate log-probability of Multinomial distribution
646-
at specified value.
642+
Calculate logp of Multinomial distribution at specified value.
647643
648644
Parameters
649645
----------
@@ -736,8 +732,7 @@ def support_point(rv, size, n, a):
736732

737733
def logp(value, n, a):
738734
"""
739-
Calculate log-probability of DirichletMultinomial distribution
740-
at specified value.
735+
Calculate logp of DirichletMultinomial distribution at specified value.
741736
742737
Parameters
743738
----------
@@ -773,6 +768,7 @@ def logp(value, n, a):
773768
class _OrderedMultinomial(Multinomial):
774769
r"""
775770
Underlying class for ordered multinomial distributions.
771+
776772
See docs for the OrderedMultinomial wrapper class for more details on how to use it in models.
777773
"""
778774

@@ -1013,8 +1009,7 @@ def dist(cls, nu, V, *args, **kwargs):
10131009

10141010
def logp(X, nu, V):
10151011
"""
1016-
Calculate log-probability of Wishart distribution
1017-
at specified value.
1012+
Calculate logp of Wishart distribution at specified value.
10181013
10191014
Parameters
10201015
----------
@@ -1047,9 +1042,10 @@ def logp(X, nu, V):
10471042

10481043
def WishartBartlett(name, S, nu, is_cholesky=False, return_cholesky=False, initval=None):
10491044
r"""
1050-
Bartlett decomposition of the Wishart distribution. As the Wishart
1051-
distribution requires the matrix to be symmetric positive semi-definite
1052-
it is impossible for MCMC to ever propose acceptable matrices.
1045+
Bartlett decomposition of the Wishart distribution.
1046+
1047+
As the Wishart distribution requires the matrix to be symmetric positive
1048+
semi-definite, it is impossible for MCMC to ever propose acceptable matrices.
10531049
10541050
Instead, we can use the Barlett decomposition which samples a lower
10551051
diagonal matrix. Specifically:
@@ -1248,6 +1244,7 @@ def update(self, node):
12481244

12491245
class _LKJCholeskyCov(Distribution):
12501246
r"""Underlying class for covariance matrix with LKJ distributed correlations.
1247+
12511248
See docs for LKJCholeskyCov function for more details on how to use it in models.
12521249
"""
12531250

@@ -1599,8 +1596,7 @@ def support_point(rv, *args):
15991596

16001597
def logp(value, n, eta):
16011598
"""
1602-
Calculate log-probability of LKJ distribution at specified
1603-
value.
1599+
Calculate logp of LKJ distribution at specified value.
16041600
16051601
Parameters
16061602
----------
@@ -1900,8 +1896,7 @@ def support_point(rv, size, mu, rowchol, colchol):
19001896

19011897
def logp(value, mu, rowchol, colchol):
19021898
"""
1903-
Calculate log-probability of Matrix-valued Normal distribution
1904-
at specified value.
1899+
Calculate logp of Matrix-valued Normal distribution at specified value.
19051900
19061901
Parameters
19071902
----------
@@ -2083,8 +2078,7 @@ def support_point(rv, rng, size, mu, sigma, *covs):
20832078

20842079
def logp(value, rng, size, mu, sigma, *covs):
20852080
"""
2086-
Calculate log-probability of Multivariate Normal distribution
2087-
with Kronecker-structured covariance at specified value.
2081+
Calculate logp of Multivariate Normal distribution with Kronecker-structured covariance at specified value.
20882082
20892083
Parameters
20902084
----------
@@ -2209,8 +2203,10 @@ def rng_fn(cls, rng: np.random.RandomState, mu, W, alpha, tau, W_is_valid, size)
22092203

22102204
class CAR(Continuous):
22112205
r"""
2212-
Likelihood for a conditional autoregression. This is a special case of the
2213-
multivariate normal with an adjacency-structured covariance matrix.
2206+
Likelihood for a conditional autoregression.
2207+
2208+
This is a special case of the multivariate normal with an
2209+
adjacency-structured covariance matrix.
22142210
22152211
.. math::
22162212
@@ -2271,8 +2267,9 @@ def support_point(rv, size, mu, W, alpha, tau, W_is_valid):
22712267

22722268
def logp(value, mu, W, alpha, tau, W_is_valid):
22732269
"""
2274-
Calculate log-probability of a CAR-distributed vector
2275-
at specified value. This log probability function differs from
2270+
Calculate logp of a CAR-distributed vector at specified value.
2271+
2272+
This log probability function differs from
22762273
the true CAR log density (AKA a multivariate normal with CAR-structured
22772274
covariance matrix) by an additive constant.
22782275
@@ -2356,9 +2353,10 @@ def rng_fn(cls, rng, size, W, sigma, zero_sum_stdev):
23562353

23572354
class ICAR(Continuous):
23582355
r"""
2359-
The intrinsic conditional autoregressive prior. It is primarily used to model
2360-
covariance between neighboring areas. It is a special case
2361-
of the :class:`~pymc.CAR` distribution where alpha is set to 1.
2356+
The intrinsic conditional autoregressive prior.
2357+
2358+
It is primarily used to model covariance between neighboring areas. It is a
2359+
special case of the :class:`~pymc.CAR` distribution where alpha is set to 1.
23622360
23632361
The log probability density function is
23642362
@@ -2541,7 +2539,9 @@ def rng_fn(cls, rng, alpha, K, size):
25412539

25422540
class StickBreakingWeights(SimplexContinuous):
25432541
r"""
2544-
Likelihood of truncated stick-breaking weights. The weights are generated from a
2542+
Likelihood of truncated stick-breaking weights.
2543+
2544+
The weights are generated from a
25452545
stick-breaking proceduce where :math:`x_k = v_k \prod_{\ell < k} (1 - v_\ell)` for
25462546
:math:`k \in \{1, \ldots, K\}` and :math:`x_K = \prod_{\ell = 1}^{K} (1 - v_\ell) = 1 - \sum_{\ell=1}^K x_\ell`
25472547
with :math:`v_k \stackrel{\text{i.i.d.}}{\sim} \text{Beta}(1, \alpha)`.
@@ -2605,8 +2605,7 @@ def support_point(rv, size, alpha, K):
26052605

26062606
def logp(value, alpha, K):
26072607
"""
2608-
Calculate log-probability of the distribution induced from the stick-breaking process
2609-
at specified value.
2608+
Calculate logp of the distribution induced from the stick-breaking process at specified value.
26102609
26112610
Parameters
26122611
----------
@@ -2688,8 +2687,8 @@ def rv_op(cls, sigma, support_shape, *, size=None, rng=None):
26882687

26892688
class ZeroSumNormal(Distribution):
26902689
r"""
2691-
ZeroSumNormal distribution, i.e Normal distribution where one or
2692-
several axes are constrained to sum to zero.
2690+
Normal distribution where one or several axes are constrained to sum to zero.
2691+
26932692
By default, the last axis is constrained to sum to zero.
26942693
See `n_zerosum_axes` kwarg for more details.
26952694

pymc/distributions/shape_utils.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
"""
16-
A collection of common shape operations needed for broadcasting
17-
samples from probability distributions for stochastic nodes in PyMC.
18-
"""
15+
"""Common shape operations to broadcast samples from probability distributions for stochastic nodes in PyMC."""
1916

2017
import warnings
2118

pymc/distributions/simulator.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ def sum_stat(cls, *args, **kwargs):
6363

6464
class Simulator(Distribution):
6565
r"""
66-
Simulator distribution, used for Approximate Bayesian Inference (ABC)
67-
with Sequential Monte Carlo (SMC) sampling via :func:`~pymc.sample_smc`.
66+
Used for Approximate Bayesian Inference with SMC sampling via :func:`~pymc.sample_smc`.
6867
6968
Simulator distributions have a stochastic pseudo-loglikelihood defined by
7069
a distance metric between the observed and simulated data, and tweaked

0 commit comments

Comments
 (0)