Skip to content

Commit

Permalink
Remove unused integrate_nd function
Browse files Browse the repository at this point in the history
  • Loading branch information
Armavica committed Sep 3, 2022
1 parent 9ad0393 commit 8223642
Showing 1 changed file with 0 additions and 38 deletions.
38 changes: 0 additions & 38 deletions pymc/tests/distributions/test_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,51 +21,13 @@
import pytest

from aesara.tensor import TensorVariable
from scipy import integrate

import pymc as pm

from pymc.distributions import MvNormal, MvStudentT, joint_logp, logp
from pymc.distributions.distribution import _moment, moment
from pymc.distributions.shape_utils import to_tuple
from pymc.tests.distributions.util import assert_moment_is_expected
from pymc.vartypes import continuous_types


def integrate_nd(f, domain, shape, dtype):
if shape == () or shape == (1,):
if dtype in continuous_types:
return integrate.quad(f, domain.lower, domain.upper, epsabs=1e-8)[0]
else:
return sum(f(j) for j in range(domain.lower, domain.upper + 1))
elif shape == (2,):

def f2(a, b):
return f([a, b])

return integrate.dblquad(
f2,
domain.lower[0],
domain.upper[0],
lambda _: domain.lower[1],
lambda _: domain.upper[1],
)[0]
elif shape == (3,):

def f3(a, b, c):
return f([a, b, c])

return integrate.tplquad(
f3,
domain.lower[0],
domain.upper[0],
lambda _: domain.lower[1],
lambda _: domain.upper[1],
lambda _, __: domain.lower[2],
lambda _, __: domain.upper[2],
)[0]
else:
raise ValueError("Dont know how to integrate shape: " + str(shape))


class TestBugfixes:
Expand Down

0 comments on commit 8223642

Please sign in to comment.