Skip to content

Commit 98ba2bf

Browse files
committed
Data type of patch must match.
1 parent ce7c7c7 commit 98ba2bf

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

tiled/_tests/test_writing.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ def test_extend_array(tree):
169169
ac.patch(ones * 8, offset=8, extend=True)
170170
numpy.testing.assert_equal(ac[8:9], ones * 8)
171171

172+
# Data type must match.
173+
with pytest.raises(ValueError):
174+
ac.patch(ones.astype("uint8"), offset=9, extend=True)
175+
172176

173177
def test_write_dataframe_full(tree):
174178
with Context.from_app(

tiled/client/array.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,11 @@ def patch(self, array: NDArray, offset: Union[int, tuple[int, ...]], extend=Fals
233233
[[0., 0.],
234234
[0., 0.]]])
235235
"""
236+
if array.dtype != self.dtype:
237+
raise ValueError(
238+
f"Data given to patch has dtype {array.dtype} which does not "
239+
f"match the dtype of this array {self.dtype}."
240+
)
236241
array_ = numpy.ascontiguousarray(array)
237242
if isinstance(offset, int):
238243
offset = (offset,)

0 commit comments

Comments
 (0)