Skip to content

Commit aeb1b77

Browse files
Add checks against time coordinate if it was set by user before calling build_statespace_graph
1 parent 960d682 commit aeb1b77

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pymc_experimental/statespace/utils/data_tools.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ def add_data_to_active_model(values, index):
114114

115115
if TIME_DIM not in pymc_mod.coords:
116116
pymc_mod.add_coord(TIME_DIM, index, mutable=True)
117+
else:
118+
found_time = pymc_mod.coords[TIME_DIM]
119+
if found_time is None:
120+
pymc_mod.coords.update({TIME_DIM: index})
121+
elif not np.array_equal(found_time, index):
122+
raise ValueError(
123+
"Provided data has a different time index than the model. Please ensure that the time values "
124+
"set on coords matches that of the exogenous data."
125+
)
126+
117127
data = pm.ConstantData("data", values, dims=data_dims)
118128

119129
return data

0 commit comments

Comments
 (0)