Skip to content
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion pymc/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1825,7 +1825,7 @@ def compile_fn(outs, mode=None, point_fn=True, model=None, **kwargs):
Compiled Aesara function as point function.
"""
model = modelcontext(model)
return model.compile_fn(outs, mode, point_fn=point_fn, **kwargs)
return model.compile_fn(outs, mode=mode, point_fn=point_fn, **kwargs)


def Point(*args, filter_model_vars=False, **kwargs) -> Dict[str, np.ndarray]:
Expand Down
19 changes: 19 additions & 0 deletions pymc/tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -966,3 +966,22 @@ def test_deterministic():

def test_empty_model_representation():
assert pm.Model().str_repr() == ""


def test_compile_fn():
with pm.Model() as m:
x = pm.Normal("x", 0, 1, size=2)
y = pm.LogNormal("y", 0, 1, size=2)

test_vals = np.array([0.0, -1.0])
state = {"x": test_vals, "y_log__": test_vals}

for target in [x, y]:
Copy link
Member

@ricardoV94 ricardoV94 Jun 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that should be the case :P (that it only accepts one output). Did we introduce that constraint somewhere by accident?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure - it's still not working with a strange error message!

with m:
func = pm.compile_fn(target)
result_compute = func(state)

func = m.compile_fn(target)
result_expect = func(state)

np.testing.assert_allclose(result_compute, result_expect)