Skip to content
Merged
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 src/probabilit/modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ class Constant(Node, OverloadMixin):
is_leaf = True # A Constant is always a leaf node

def __init__(self, value):
self.value = value
self.value = value.value if isinstance(value, Constant) else value
super().__init__()

def _sample(self, size=None):
Expand Down
5 changes: 5 additions & 0 deletions tests/test_modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ def test_single_expression():
np.testing.assert_allclose(samples, 2)


def test_constant_idempotent():
for a in [-1, 0.0, 1.3, 3]:
assert Constant(Constant(a)).value == Constant(a).value


if __name__ == "__main__":
import pytest

Expand Down