Skip to content

Commit f1f3d38

Browse files
Add type checking and errors for property combination
1 parent 22072ac commit f1f3d38

File tree

1 file changed

+12
-0
lines changed
  • pymc_extras/statespace/models/structural

1 file changed

+12
-0
lines changed

pymc_extras/statespace/models/structural/core.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,18 @@ def _combine_property(self, other, name, allow_duplicates=True):
745745
self_prop = getattr(self, name)
746746
other_prop = getattr(other, name)
747747

748+
if not isinstance(self_prop, type(other_prop)):
749+
raise TypeError(
750+
f"Property {name} of {self} and {other} are not the same and cannot be combined. Found "
751+
f"{type(self_prop)} for {self} and {type(other_prop)} for {other}'"
752+
)
753+
754+
if not isinstance(self_prop, list | dict):
755+
raise TypeError(
756+
f"All component properties are expected to be lists or dicts, but found {type(self_prop)}"
757+
f"for property {name} of {self} and {type(other_prop)} for {other}'"
758+
)
759+
748760
if isinstance(self_prop, list) and allow_duplicates:
749761
return self_prop + other_prop
750762
elif isinstance(self_prop, list) and not allow_duplicates:

0 commit comments

Comments
 (0)