Skip to content

Commit 12be097

Browse files
committed
Remove unused sigmoid import
1 parent 3114ec2 commit 12be097

File tree

1 file changed

+30
-24
lines changed

1 file changed

+30
-24
lines changed

pymc3/distributions/multivariate.py

+30-24
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@
2525
from aesara.graph.basic import Apply
2626
from aesara.graph.op import Op
2727
from aesara.tensor.nlinalg import det, eigh, matrix_inverse, trace
28-
from aesara.tensor.random.basic import MultinomialRV, dirichlet, multivariate_normal, RandomVariable
28+
from aesara.tensor.random.basic import (
29+
MultinomialRV,
30+
RandomVariable,
31+
dirichlet,
32+
multivariate_normal,
33+
)
2934
from aesara.tensor.random.op import default_shape_from_params
3035
from aesara.tensor.random.utils import broadcast_params
3136
from aesara.tensor.slinalg import (
@@ -45,7 +50,7 @@
4550
from pymc3.distributions.dist_math import bound, factln, logpow
4651
from pymc3.distributions.distribution import Continuous, Discrete
4752
from pymc3.distributions.special import gammaln, multigammaln
48-
from pymc3.math import kron_diag, kron_dot, kron_solve_lower, kronecker, sigmoid
53+
from pymc3.math import kron_diag, kron_dot, kron_solve_lower, kronecker
4954

5055
__all__ = [
5156
"MvNormal",
@@ -155,7 +160,7 @@ def quaddist_tau(delta, chol_mat):
155160

156161

157162
class MvNormal(Continuous):
158-
R"""
163+
r"""
159164
Multivariate normal log-likelihood.
160165
161166
.. math::
@@ -250,7 +255,7 @@ def _distr_parameters_for_repr(self):
250255

251256

252257
class MvStudentT(Continuous):
253-
R"""
258+
r"""
254259
Multivariate Student-T log-likelihood.
255260
256261
.. math::
@@ -363,7 +368,7 @@ def _distr_parameters_for_repr(self):
363368

364369

365370
class Dirichlet(Continuous):
366-
R"""
371+
r"""
367372
Dirichlet log-likelihood.
368373
369374
.. math::
@@ -452,7 +457,7 @@ def rng_fn(cls, rng, n, p, size):
452457

453458

454459
class Multinomial(Discrete):
455-
R"""
460+
r"""
456461
Multinomial log-likelihood.
457462
458463
Generalizes binomial distribution, but instead of each trial resulting
@@ -527,9 +532,7 @@ class DirichletMultinomialRV(RandomVariable):
527532
_print_name = ("DirichletMN", "\\operatorname{DirichletMN}")
528533

529534
def _shape_from_params(self, dist_params, rep_param_idx=1, param_shapes=None):
530-
return default_shape_from_params(
531-
self.ndim_supp, dist_params, rep_param_idx, param_shapes
532-
)
535+
return default_shape_from_params(self.ndim_supp, dist_params, rep_param_idx, param_shapes)
533536

534537
@classmethod
535538
def rng_fn(cls, rng, n, a, size):
@@ -561,7 +564,7 @@ def rng_fn(cls, rng, n, a, size):
561564

562565

563566
class DirichletMultinomial(Discrete):
564-
R"""Dirichlet Multinomial log-likelihood.
567+
r"""Dirichlet Multinomial log-likelihood.
565568
566569
Dirichlet mixture of Multinomials distribution, with a marginalized PMF.
567570
@@ -616,10 +619,18 @@ def logp(value, n, a):
616619
-------
617620
TensorVariable
618621
"""
622+
n = intX(n)
623+
a = floatX(a)
624+
if value.ndim >= 1:
625+
n = at.shape_padright(n)
626+
if a.ndim > 1:
627+
a = at.shape_padleft(a)
628+
619629
sum_a = a.sum(axis=-1, keepdims=True)
620630
const = (gammaln(n + 1) + gammaln(sum_a)) - gammaln(n + sum_a)
621631
series = gammaln(value + a) - (gammaln(value + 1) + gammaln(a))
622632
result = const + series.sum(axis=-1, keepdims=True)
633+
623634
# Bounds checking to confirm parameters and data meet all constraints
624635
# and that each observation value_i sums to n_i.
625636
return bound(
@@ -686,7 +697,7 @@ def __str__(self):
686697

687698

688699
class Wishart(Continuous):
689-
R"""
700+
r"""
690701
Wishart log-likelihood.
691702
692703
The Wishart distribution is the probability distribution of the
@@ -798,7 +809,7 @@ def logp(self, X):
798809

799810

800811
def WishartBartlett(name, S, nu, is_cholesky=False, return_cholesky=False, initval=None):
801-
R"""
812+
r"""
802813
Bartlett decomposition of the Wishart distribution. As the Wishart
803814
distribution requires the matrix to be symmetric positive semi-definite
804815
it is impossible for MCMC to ever propose acceptable matrices.
@@ -903,7 +914,7 @@ def _lkj_normalizing_constant(eta, n):
903914

904915

905916
class _LKJCholeskyCov(Continuous):
906-
R"""Underlying class for covariance matrix with LKJ distributed correlations.
917+
r"""Underlying class for covariance matrix with LKJ distributed correlations.
907918
See docs for LKJCholeskyCov function for more details on how to use it in models.
908919
"""
909920

@@ -1083,7 +1094,7 @@ def _distr_parameters_for_repr(self):
10831094

10841095

10851096
def LKJCholeskyCov(name, eta, n, sd_dist, compute_corr=False, store_in_trace=True, *args, **kwargs):
1086-
R"""Wrapper function for covariance matrix with LKJ distributed correlations.
1097+
r"""Wrapper function for covariance matrix with LKJ distributed correlations.
10871098
10881099
This defines a distribution over Cholesky decomposed covariance
10891100
matrices, such that the underlying correlation matrices follow an
@@ -1236,7 +1247,7 @@ def LKJCholeskyCov(name, eta, n, sd_dist, compute_corr=False, store_in_trace=Tru
12361247

12371248

12381249
class LKJCorr(Continuous):
1239-
R"""
1250+
r"""
12401251
The LKJ (Lewandowski, Kurowicka and Joe) log-likelihood.
12411252
12421253
The LKJ distribution is a prior distribution for correlation matrices.
@@ -1379,20 +1390,15 @@ def logp(self, x):
13791390
result = _lkj_normalizing_constant(eta, n)
13801391
result += (eta - 1.0) * at.log(det(X))
13811392
return bound(
1382-
result,
1383-
X >= -1,
1384-
X <= 1,
1385-
matrix_pos_def(X),
1386-
eta > 0,
1387-
broadcast_conditions=False,
1393+
result, X >= -1, X <= 1, matrix_pos_def(X), eta > 0, broadcast_conditions=False
13881394
)
13891395

13901396
def _distr_parameters_for_repr(self):
13911397
return ["eta", "n"]
13921398

13931399

13941400
class MatrixNormal(Continuous):
1395-
R"""
1401+
r"""
13961402
Matrix-valued normal log-likelihood.
13971403
13981404
.. math::
@@ -1651,7 +1657,7 @@ def _distr_parameters_for_repr(self):
16511657

16521658

16531659
class KroneckerNormal(Continuous):
1654-
R"""
1660+
r"""
16551661
Multivariate normal log-likelihood with Kronecker-structured covariance.
16561662
16571663
.. math::
@@ -1898,7 +1904,7 @@ def _distr_parameters_for_repr(self):
18981904

18991905

19001906
class CAR(Continuous):
1901-
R"""
1907+
r"""
19021908
Likelihood for a conditional autoregression. This is a special case of the
19031909
multivariate normal with an adjacency-structured covariance matrix.
19041910

0 commit comments

Comments
 (0)