Skip to content

Commit 4ab748c

Browse files
check for original coords
1 parent ab593b1 commit 4ab748c

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

pymc/model.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,16 +1179,17 @@ def set_data(
11791179
# Reject resizing if we already know that it would create shape problems.
11801180
# NOTE: If there are multiple pm.MutableData containers sharing this dim, but the user only
11811181
# changes the values for one of them, they will run into shape problems nonetheless.
1182-
length_belongs_to = length_tensor.owner.inputs[0].owner.inputs[0]
1183-
if not isinstance(length_belongs_to, SharedVariable) and length_changed:
1184-
raise ShapeError(
1185-
f"Resizing dimension '{dname}' with values of length {new_length} would lead to incompatibilities, "
1186-
f"because the dimension was initialized from '{length_belongs_to}' which is not a shared variable. "
1187-
f"Check if the dimension was defined implicitly before the shared variable '{name}' was created, "
1188-
f"for example by a model variable.",
1189-
actual=new_length,
1190-
expected=old_length,
1191-
)
1182+
if original_coords is None:
1183+
length_belongs_to = length_tensor.owner.inputs[0].owner.inputs[0]
1184+
if not isinstance(length_belongs_to, SharedVariable) and length_changed:
1185+
raise ShapeError(
1186+
f"Resizing dimension '{dname}' with values of length {new_length} would lead to incompatibilities, "
1187+
f"because the dimension was initialized from '{length_belongs_to}' which is not a shared variable. "
1188+
f"Check if the dimension was defined implicitly before the shared variable '{name}' was created, "
1189+
f"for example by a model variable.",
1190+
actual=new_length,
1191+
expected=old_length,
1192+
)
11921193
if original_coords is not None and length_changed:
11931194
if length_changed and new_coords is None:
11941195
raise ValueError(

0 commit comments

Comments
 (0)