Skip to content

Commit 130671f

Browse files
added test
1 parent 8e2ff0a commit 130671f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

pymc/model.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,8 @@ def set_data(
12291229
actual=len(new_coords),
12301230
expected=new_length,
12311231
)
1232-
self._coords[dname] = new_coords
1232+
# store it as tuple for immutability as in add_coord
1233+
self._coords[dname] = tuple(new_coords)
12331234

12341235
shared_object.set_value(values)
12351236

pymc/tests/test_data_container.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,10 @@ def test_explicit_coords(self):
316316
# pass coordinates explicitly, use numpy array in Data container
317317
with pm.Model(coords=coords) as pmodel:
318318
pm.MutableData("observations", data, dims=("rows", "columns"))
319-
319+
# new data with same shape
320+
pm.set_data({"observations":data+1})
321+
# new data with same shape and coords
322+
pm.set_data({"observations":data},coords=coords)
320323
assert "rows" in pmodel.coords
321324
assert pmodel.coords["rows"] == ("R1", "R2", "R3", "R4", "R5")
322325
assert "rows" in pmodel.dim_lengths

0 commit comments

Comments
 (0)