Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set different almost equal tolerance depending on floatX #3980

Merged
merged 1 commit into from
Jun 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions pymc3/tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from pymc3.distributions import HalfCauchy, Normal, transforms
from pymc3 import Potential, Deterministic
from pymc3.model import ValueGradFunction
from .helpers import select_by_precision


class NewModel(pm.Model):
Expand Down Expand Up @@ -192,17 +193,33 @@ def test_matrix_multiplication():
tune=0,
compute_convergence_checks=False,
progressbar=False)
decimal = select_by_precision(7, 5)
for point in posterior.points():
npt.assert_almost_equal(point['matrix'] @ point['transformed'],
point['rv_rv'])
npt.assert_almost_equal(np.ones((2, 2)) @ point['transformed'],
point['np_rv'])
npt.assert_almost_equal(point['matrix'] @ np.ones(2),
point['rv_np'])
npt.assert_almost_equal(point['matrix'] @ point['rv_rv'],
point['rv_det'])
npt.assert_almost_equal(point['rv_rv'] @ point['transformed'],
point['det_rv'])
npt.assert_almost_equal(
point['matrix'] @ point['transformed'],
point['rv_rv'],
decimal=decimal,
)
npt.assert_almost_equal(
np.ones((2, 2)) @ point['transformed'],
point['np_rv'],
decimal=decimal,
)
npt.assert_almost_equal(
point['matrix'] @ np.ones(2),
point['rv_np'],
decimal=decimal,
)
npt.assert_almost_equal(
point['matrix'] @ point['rv_rv'],
point['rv_det'],
decimal=decimal,
)
npt.assert_almost_equal(
point['rv_rv'] @ point['transformed'],
point['det_rv'],
decimal=decimal,
)


def test_duplicate_vars():
Expand Down